Why would John the Baptist have doubted Jesus was the Messiah?
John was experiencing much pressure during this time. He had been in the desert for a few months prior to Jesus even coming on the scene. If we put ourselves into that frame of thought, knowing that we had some great news, we know that God had told us this great news, but when we see other people question what we do, it can begin to bring up insecurity within our own self, to make us ask “Did I get it right?”
At that time there was undergoing a Sanhedrin investigation. The Pharisees went out to observe any occurrences of Messianic movement happening. The reason they would come a second time was if the claims were true and they were seeing people respond to the movement, the Pharisees saw that as a direct threat (to them). Their goal now is to shut it down and sabotage whatever John is doing in the wilderness at that particular moment.
So as John gets captured and sent to prison (for calling people to repent and for calling the King out on his own sin of laying with his brother’s wife). John, being obedient to do what God has called him to do, cannot reconcile how he has now found himself in prison. John’s conundrum is that while he is suffering in prison, he expected there to be victory (in the arrival of the Messiah).
This was not an uncommon thought - the people thought that this coming Kingdom would be one to wipe out all the nations and would reign supreme. But the way in which this coming was happening was unlike no other; that it wold first require suffering in order for the victory to be seen.
In Matthew 11 Jesus lets His disciples know what is happening, and tells them to go back to John to let him know these things are happening and being fulfilled. What is happening to John is ultimately foreshadowing what is going to happen to Jesus on the cross.