I know Hz. Mohammed's heart surgery when he was a child living with his wet nurse Hz. Halime.
Allah's Messenger said, "While I was at Mecca the roof of my house was opened and Gabriel descended, opened my chest, and washed it with Zamzam water. Then he brought a golden tray full of wisdom and faith and having poured its contents into my chest, he closed it. ..." (sunnah.com)
I read that the aim of the surgery was to purify his heart from the iniquities. Was Hz. Mohammed not capable of avoiding sin if this surgery wasn't performed? What was the reason for this surgery? Did other prophets undergo such surgeries?