All perfect praise be to Allah, The Lord of the Worlds. I testify that there is none worthy of worship except Allah, and that Muhammad is His slave and Messenger.
The rulings of the Sharee'ah are received from Allah Almighty and also from His Prophet . Whatever the Prophet has forbidden takes the same status as that which Allah has forbidden, because he is His Messenger and is entrusted with His Revelation, so the Prophet cannot lie on Allah.
In His Book, Allah rebuked those who did not forbid what the Prophet forbade; Allah Says (what means): {…and who do not consider unlawful what Allah and His Messenger have made unlawful.} [Quran 9:29]
Moreover, Al-Miqdaam ibn Ma’di Karb Al-Kindi narrated that the Prophet said: "Soon there will come a time when a man will be reclining on his pillow, and when one of my Ahaadeeth is narrated to him, he will say: 'The Book of Allah is (sufficient) between us and you. Whatever it states to be permissible, we will take as permissible, and whatever it states to be forbidden, we will take as forbidden.' Verily, whatever the Messenger of Allah has forbidden is like that which Allah has forbidden." [Ahmed and Ibn Maajah]
As regards the Hadeeth you mentioned "I was about to prohibit Gheelah but I remembered that the Romans and the Persians practiced it, without any harm being caused to their children." [Muslim] Gheelah is when a man has intercourse with his wife while she is suckling a child.
At the beginning, the Prophet with his own Ijtihaad (judgement) was about to forbid Gheelah, out of fear that the breastfed child will be harmed. This is because it was common to them (Arabs) that if the husband has intercourse with his wife while she is breastfeeding, the child will be harmed, so the Arabs hated it and feared it. However, when he saw that the (children of the) Persians and the Romans were not harmed by that milk, he refrained from forbidding Gheelah, as the reason that required the prohibition (the harm) no longer existed. Sometimes the Prophet would make Ijtihaad according to his predominant judgement, but he was never left (uncorrected by Allah without correction) when he made a wrong Ijtihaad.
Perhaps the wisdom behind him making Ijtihaad on a matter and then not being approved on it, is to show his trustworthiness in conveying whatever is revealed to him, and that he immediately abandons his opinion when something contrary is revealed to him, and he conveys that to his nation. He never disdained from doing so nor was he ever arrogant (and abstained from correcting his wrong Ijtihaad). He fulfilled the trust, conveyed the message, and advised his nation until he passed away.
Allah knows best.