They made errors but not sins
It is correct that according to Islam all prophets of Allah ﷻ were without sins including Prophet Adam (alaihi salaam). These holy personalities committed errors and mistakes and while their errors apparently seem to be sins, yet, in the light of Quran they are not the same as sins of common people. This is because in their case their acts were not the same as someone who desires and intends to sin and commits due to love and addiction of it.
Sin of Adam (alaihi salaam)
Prophet Adam (a.s) did not deliberately sin, in fact it was an act predestined by Allah ﷻ because it served a larger purpose of humankind’s existence. After all Prophet Adam (a.s) was not created to remain in the heavens with Hawwa (Eve) (alaihi salaam), they were created to live on earth so that their future generations may be tested which is the main purpose of our existence here on earth. This is correct as per Quran where Allah ﷻ had already informed the angels of His plan before He was going to create Adam : “And Your Sustainer said to the angels: "Behold, I am about to establish upon earth one who shall inherit it.” Prophet Muhammad ﷺ narrated to us a discussion that once took place between Prophet Adam (a.s) and Prophet Musa (Moses) (a.s) which inform us about the predestination of this act: “Adam and Musa met, and Musa said, ‘You are the one who made things difficult for mankind and you caused them to be evicted from Paradise.’ Adam said, ‘Are you the one whom Allah chose for His Message, and He selected you for Himself and He revealed the Tawrah to you'’ Musa replied, ‘Yes.’ Then Adam said, ‘Did you find that it was preordained upon me before He (Allah) created me'’ Musa replied, ‘Yes.’ Therefore, Adam defeated Musa's argument.” Unlike earth, the development stages for humans as they mature naturally was not in place in the heavens. It seems as Prophet Adam (a.s) nature at that moment was in a dormant state, a state of innocence where his mind was not fully developed to retract from a wrong decision he had already made. Just as a child is warned not to approach a hot stove or cup of hot coffee but they in their ignorance touch it and once they feel the burn they withdraw and cry. Thus what Prophet Adam (a.s) did was an act of disobedience which is defined as a sin because he crossed the boundary of Allah ﷻ i.e. “The Tree”, but it was not considered at the same level as that of a mature person who completely understands right from wrong. Just like the saying that an error of a person is as big as his intellect because such a person’s error is weighed against the maturity of their intellect. The heavenly environment of Prophet Adam (a.s) was not suitable for the complete development of his intellect faculty and thus his sin is not the same as that of any adult person who knowingly commits sins.
Understanding the so called sins of other Prophets
All other Prophets mentioned in the Quran, many of whom are also mentioned in bible, never committed a sin for the sake of it, though they made errors and mistakes, which was natural due to their human nature. These errors were mainly of two types:
1. Errors made during early part of their lives before prophethood, which were committed without the intention to commit disobedience, but they happened due to their human nature. Nevertheless, they immediately repented as a result which they were forgiven.
2. Errors made when practicing ijtihad (reasoning) which they made use of to arrive at a better decision during their preaching. At such a moment, they were immediately corrected by revelation from Allah ﷻ and provided a better solution.
Prophet Muhammad ﷺ error while preaching
For instance in Surah Abasa (Chapter 80 of the Quran) Prophet Muhammad ﷺ was corrected in regards to his decision when he preached the influential Makkan chiefs and overlooked a poor blind man named Ibn Umm Maktum: “He frowned and turned away because the blind man approached him! Yet for all you did know, [O Muhammad,] he might perhaps have grown in purity, or have been reminded [of the truth], and helped by this reminder.” The Prophet ﷺ was immediately corrected in regards to his decision and after this incident became cautious in his approach of dawah (preaching). He then preached umm Maktum who accepted Islam and became one of the greatest companions.
Prophet Suleiman (Solomon) (alaihi salaam) judges better than Prophet Dawud (David) (alaihi salaam)
Then we have the case of Prophet Dawud (David) (alaihi salaam) who once made a decision in regards to a case brought to him by two persons, one whose sheep destroyed the crops of the other. Prophet Dawud (a.s) gave the judgment that the sheep roughly had the same value as that of destroyed crops so the crop owner should get all the sheep. On the other hand, his son Prophet Sulaiman (Solomon) (alaihi salaam) suggested giving the sheep to the crop owner temporarily until his crops grow back meanwhile, he can use the sheep for his use (of milk, wool, new born lambs etc.). Once the crops grow back he should return the sheep to its owner and this way both will be compensated. Prophet David (a.s) judgment was good but Prophet Sulaiman (a.s) judgment was better: “and [remember] David and Solomon - [how it was] when both of them gave judgment concerning the field into which some people's sheep had strayed by night and pastured therein, and [how] We bore witness to their judgment.”
Prophet Yunus (Jonah) (alaihi salaam) error in judgment
Consider the case of Prophet Yunus (Jonah) (a.s) after facing much opposition from his people warned them and made the decision to abandon them even though Allah ﷻ had not yet revealed to him to make such decision: “and [remember] him of the great fish - when he went off in wrath, thinking that We had no power over him!” After abandoning them, his people realized their error and sought forgiveness and Allah ﷻ guided them. But Prophet Yunus (a.s) committed an act of disobedience towards Allah ﷻ by not being patient enough for his people to become responsive. In this case the error in decision making was of a severe nature from a prophetic perspective. When people of Sodom and Gomorrah were going be punished Prophet Lut (Lot) (alaihi salaam) did not abandon them till he was specifically instructed by Allah ﷻ to do so: “(O Lot) Go, then with your household while it is yet night, with yourself following them in the rear;” Similar was the case of Prophet Nuh (Noah) (alaihi salaam) as well as Prophet Musa (Moses) (alaihi salaam) who decided to leave their people or land only after Allah ﷻ commanded them to so and not before. Mind you that the disobedience of Prophet Yunus (a.s) was not against Allah’s religious commandments and prohibitions of a divine law given to common people, it was against a prophetic law, which does not apply to commoners. Nevertheless, it was a disobedience against a prophetic law for which he repented and was forgiven: “but then he cried out in the deep darkness, ‘There is no God but You, glory be to You, I was wrong.’ We answered him and saved him from distress: this is how We save the faithful.”
Prophet Musa (Moses) (alaihi salaam) unintentionally kills an Egyptian
Let’s take another case where Prophet Musa (a.s) hit an Egyptian and killed him with the first strike. Please note this happened before prophethood was given to him, as confirmed in the Quran: “I committed it while I was still going astray.” In the scenario the intention was not to kill, the intention was to hurt the apparent wrongdoer while actual wrongdoer was the Israeli man. Under the influence of sympathetic emotions for the Israeli, Prophet Musa (a.s) overlooked the fact who real culprit was and hit the Egyptian who died. Over here, even though it was an act of killing yet the intention was never to murder, the intention was to scare him away: “whereupon Moses struck him down with his fist, and [thus] brought about his end. [But then] he said [to himself]: "This is of Satan's doing! Verily, he is an open foe, leading [man] astray!" [And] he prayed: O my Sustainer! Verily, I have sinned against myself! Grant me, then, Your forgiveness!" And He forgave him - for, verily, He alone is truly forgiving, a dispenser of grace.” As per prophetic hadith ‘Actions will be judged according to intentions’ and this is a universal law for all humanity. Since the intention was not murder therefore Prophet Musa (a.s) committed this act of error under human emotions and prophets are not immune from such emotions.
Prophet Dawud (David) (alaihi salaam) was corrected
There is another scenario pertaining to Prophet Dawud (David) (a.s) in which he admired the beauty of his general’s only wife and intended to marry her despite the fact that himself had several beautiful wives. Right at that moment Allah ﷻ presented for him a case to decide that immediately gave him the consciousness that he was being tested: “…This is my brother. He had ninety-nine sheep and I just the one, and he said, “Let me take charge of her,” and overpowered me with his words.’ David said, ‘He has done you wrong by demanding to add your (only) sheep to his flock. Many partners treat each other unfairly. Those who sincerely believe and do good deeds do not do this, but these are very few.’ [Then] David realized that We had been testing him, so he asked his Lord for forgiveness, fell down on his knees, and repented.” This happened when Prophet Dawud (a.s) was ruling as a king and preaching as a prophet. This incident informs us that despite the fact when revelation descended on a prophet yet they are not immune from weakness of human nature. When they are influenced by such emotions during prophetic mission then they are immediately corrected by Allah ﷻ so they realize and correct their inner selves. Prophet Dawud (a.s) was corrected, he repented before Allah ﷻ for such a thought and it was accepted. Unlike Bible the Quran opposes the allegation that he committed an act of adultery with his general’s wife. Somewhat similar applied to the instance of Prophet Yusuf (Joseph) (alaihi salaam) when the wife of his Egyptian master tried seducing him and due to his manly emotions he too was inclined towards her but held himself back and Allah ﷻ had mercy on him which protected him from an act of sin: “And, indeed, she desired him, and he desired her; [and he would have succumbed] had he not seen [in this temptation] an evidence of his Sustainer's truth.” As opposed to Prophet Dawud (a.s) who carried inclination towards the beautiful wife of his army general, Prophet Yusuf was completely innocent, it was the woman who attempted to seduce him yet he did not overrule the inclination of his own desires. Both these cases prove that human emotions were prevalent within both prophets.
These scenarios inform us that the prophets never committed major sins like common people, Allah ﷻ had protected them against it. They committed errors and mistakes, which may be defined as minor sins but these too, were not committed with the intention to disobey, they were committed due to their ignorance or under emotions.
 Al Quran 2:30 – Asad Translation
 Al-Bukhari and Muslim - Surah 20. Ta-ha, Ayaat 40 To 44 - I. I. Kathir 2003
 Al Quran 80:1–4 – Asad Translation.
 Al Quran 21:78 – Asad Translation
 Al Quran 21:87 – Asad Translation
 Al Quran 15:65 – Asad Translation
 Al Quran 21:87-88
 Al Quran 26:20
 Al Quran 26:15 – Asad Translation
 Al Quran 38:22–24
 Al Quran 12:24 – Asad Translation