Salaam all,
I think that we should remember that the Quran gives us snapshots of conversations. I am sure prophet Joseph said more things to his two companions in jail. He could have said inshAllah to them at some point. Just because it is not mentioned, does not mean that he did not say it.
Also we should look at the incidents of when other prophets erred and their mention in the Quran. God tells us what their mistakes were, the subsequent realization of them and how they were forgiven because they repented.
Prophet Jonah, David and Soloman are examples. They were chosen by God, but as they are humans, they made mistakes, some that we are told about.
In prophet Joseph's story, we are not told of any mistake he made, as we are with the others, which leads me to think that by staying in jail for longer, it was not a punishment from God for something he did or didn't do. If that was the case, we would have been told about it .