Mistakes By Prophets
Prophets were under God’s protection to ensure Divine directives are delivered in ultimate form to rule out any doubts. When that protection is removed for a moment then Prophet made mistakes (just like other human beings) but those were immediately corrected by Divine intervention. There was a hidden lesson in it: Subhan Allah (“God is perfect (free of any errors/defects)”
I don’t think that it’s correct to assume that the protection of prophets get removed. However, we have to understand that prophets were not in a constant state of ‘wahi’. They were human beings who lived in their respective societies, inferred ideas from their experiences, had human emotions, and were prone to making errors like the rest of us. When they made any such errors in regards to deen, God would always correct them, hence the knowledge we got from them is infallible. Examples of such errors can be can be found in the corpus of the Quran and the hadith. For example, prophet Yunus AS left his people too early in despair (21:87-88), prophet Muhammad SAW advised Khawalah to go easy on her husband who had made zihar with her upon which verses 58:1-4 were revealed, and prophet Muhammad frowning at Abdullah ibn Umm-Maktum (blind man) upon which beginning verses of chapter 80 were revealed.