Fear is simply negative faith. Where did this fear come from? Second Timothy 1:7 says, "For God hath not given us the spirit of fear; but of power and of love, and of a sound mind." It didn't come from God. This fear was able to come upon Peter because he took his attention off of Jesus and put it on his situation.
Fear or doubt cannot "just overcome" us. We have to let it in. If Peter had kept his attention on Jesus, the author and finisher of his faith (Hebrews 12:2), he wouldn't have feared. In the same way that faith comes by hearing the Word of God (Romans 10:17), fear comes by hearing or seeing something contrary to God's Word.
The wind and waves didn't really have anything to do with Peter walking on the water. He couldn't have walked on the water without Jesus even if it had been calm. The circumstances simply took Peter's attention off of his Master. Satan tries to distract us with thinking about our problems.
Peter's faith didn't fail him all at once, as can be seen by the fact that he only "began" to sink. If there had been no faith present, he would have sunk all at once and not gradually. This shows us that the entrance of fear and the exit of faith do not happen instantly.
There are always signs that this is happening. If we will turn our attention back to Jesus, as Peter did, He will save us. No problem is too big for God. We should cast our care about the problem over on God and just keep our eyes on Jesus, the Word.