I have read this question and I have also studied in school that Prophets are sinless. Today I read in the Quran that Moosa killed a man. Here are the verses that describe the scene. I read at another place that he 'accidentally' killed him. I don't find it accidental myself (Musa struck him with his fist and he died.) Are Prophets sinless? Even if he hit the guy with his fist, its considered a sin.
Note that عصمة of the Prophets is agreed upon by the Muslims, however they differed on what it entails and from when it is applicable. For example, according to the Ahlul Sunnah it entails protection from intentional sins but not mistakes and forgetfulness, for some also it entails protection from major sins but not from some minor sins. For some, such as the Shia, it entails protection from even mistakes.
The killing of the Egyptian by Moses (عليهم السلام) was not a sin, but an unintentional mistake. The evidence for this includes the hadith of the Prophet ﷺ:
وإنما قتل موسى الذي قتل من آل فرعون خطأ
Moses killed a person from among the people of Pharaoh unintentionally
Further Mufassirs have also given the following explanations:
The Egyptian was a Harbi, whose blood is permitted. At most it was preferable to handle the situation differently rather than to kill him. Leaving what is recommended for what is permitted is not a sin.
He had not yet received Prophethood at the time of this incident, so the viewpoint of those who claim that infallibility is only after prophethood is satisfied.