Some call it distraction. Others call it prayer ADD. And some people say it's just Satan. Whatever you call it, you've probably encountered it: you start praying, and then your mind just starts thinking about something else, anything else, and then everything else. You're not alone. Probably everybody who has ever tried to pray for more than a few minutes has experienced his or her mind starting to wonder.
It's normal and it makes us feel pretty terrible. We all want to know how to get past that. We all think it would be great if we could be the kind of prayers who could just sit for hours and not think about anything else except the prayer request we should be praying for. That's pretty unrealistic. Also, that's not really the great prayer life we all think we want. In fact, that prayer ADD may not be the curse we think it is after all.
When your mind starts wonder, you first need to stop acting like it's a crime. Recognize that sometimes God interrupts, distracts, or re-tracks you for a reason. When you try to pray but a thought relentlessly keeps popping up in your head, start talking to God about it. Don't try to forget it because it might be God telling you that He wants you to think about it. It may feel really weird, but just let your mind wander over the persistent idea. For example, a while back I would often pray about what our church needed to do to reach out to the community. These distracting thoughts kept coming into my mind of how different church members could help the community when I was trying to pray for other stuff. For a while I really tried to get rid of those thoughts because they weren't what I was "supposed" to be praying for. They kept coming, though, so I just let my mind kind of zone out and think about them. It was during that sort of time of letting God show me what He wanted me to see that I realized so much of what our church needed to do to reach out to our community. Sometimes those distracting thoughts you can't get rid of are actually God saying, "Hey, just listen to me."
Other times, your thoughts are really your thoughts distracting you while you pray. Again, you shouldn't act like those thoughts are something you should hush and hide from God. If it really is something you shouldn't be thinking about at all, ask God to help you refocus and, if necessary, for forgiveness. If a worry or concern or even just a thought keeps pulling you away from what you're trying pray for, talk to God about it. Sometimes (a lot of the time) I start wondering what I'm going to have for lunch while I'm praying. Instead of thinking, "Oh man, I shouldn't be thinking this right now" I ask God what I should have for lunch. Often He quite quickly leads my mind to think of something quite delicious, I feel satisfied, and I go back to praying for the other stuff. If you keep distracting yourself, don't worry about talking to God about it; He wants you talking to Him about everything anyway. That's really the key to praying. God wants to talk to you and He wants you to talk to Him. So don't be afraid to talk to Him about anything and everything and all the things that your mind wanders about.