Here is an extract from the Commentary of Puya:
[Pooya/Ali Commentary 47:19]
bin Muhammad as Sadiq said: "Just as a flutter of wind or a strong
shaking brings the dried leaves of a tree on the ground, istighfar
helps man to get rid of sins."
Aqa Mahdi Puya says: Istighfar is a
request made to Allah to keep the supplicant free from sinning by His
grace and mercy. It is the highest form of worship. Every true servant
of Allah uses this means to stay away from falling unintentionally
into the pit of sin and evil, but a divinely commissioned leader
(Imam) not only prays for himself but also for those who follow him,
because their welfare is his responsibility.
Prophets, according to the Qur'an, are infallible. This doesn't mean that they can't commit sin, rather it means that they won't because they are of the highest spiritual and intellectual consciousness. They see the reality of their actions as it truly is and it's consequences.
As for mistakes, they don't make mistakes in religious matters either, Nor in non-religious matters. Contradictory to what @shoerat had said.
For if the prophet made mistakes, then one could question all the decisions and actions of the Prophet.
In the Qur'an, it testifies that prophet and his household were purified a thorough and Constant purification:
And establish prayer and give zakah and obey Allah and His Messenger. Allah intends only to
remove from you the impurity , O people of the [Prophet's] household,
and to purify you with Thorough purification. [Sahih International
Allah constantly tells us to obey the Prophet. If the prophet was susceptible to committing sins or mistakes. Then this would not make sense.
Also in the Qur'an, Allah(swt) says that Sheytan promised to stay away from those who are infallible as he said that he would deceive everyone except Allah's chosen servants:
Except, among them, Your chosen servants. [Sahih International 15:40]