“Verily, all actions are but driven by intention and for everyone is what he intended.” [Bukhari and Muslim]
From this hadith, we can conclude that everything comes down to your intention. If your intention is to do an evil act, you will be accounted for that evil act (this is what i understand you were referring to as a 'sin') If however you did something against the command of god in unawareness, it would be referred to as a mistake, as it was unintentional.
Prophets were sent to deliver messages of religion to their people. For this reason, sin would be the wrong word to use on them, rather they made mistakes as all humans did. So prophets did make mistakes, and these mistakes could be something we learn from, but they did not commit sins.