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.
As for mistakes, they don't make mistakes in religious matters either, however there have been debates regarding mistakes in non-religious matters.
In the Qur'an, it testifies that prophet and his household were purified a thorough purification:
And abide in your
houses and do not display yourselves as [was] the display of the
former times of ignorance. 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 33:33]
Also in the Qur'an, Allah(swt) says that Sheytan promised to stay away from those who were infallible as he said that he would deceive everyone except Allah's chosen servants:
Except, among them, Your chosen servants.
[Sahih International 15:40]
This also makes logical sense: how can you have clean water (Qur'an) through an impurfied carrier? Prophets must be clean of error or sins so they don't get questioned.
If they are open to make mistakes (about religious matters), then one can question the entire religion because how does one know if the prophet is making a mistake about his Sunnah or even the Qur'an. Hence a comprehensive approach of the holy Qur'an and logic only justifies spiritual and intellectual perfection of prophet. In an authentic hadith, the prophet said that he was "the city of knowledge (and wisdom)". Such a claim can only come from one who is infallible.
Allah (swt) also said in many verses of the Qur'an that we need to follow the prophet as we follow Allah and submit to him (i.e the prophet).
Surely Allah and His Angels shower prayers on the Prophet. O you who
have believed, pray for for him, and submit in full submission.
[Dr. Ghali 33:56]
In the Qur'an, in order to find answers one should, in my humble opinion, read it more comprehensively. Humans can have a million questions, and if they were looking for a million direct and easy answers the Qur'an would never finish. Therefore reading it with open eyes, heart, and intellect can lead to many answers.
And Allah (swt) knows the best.