Summary: The devil brings vain thoughts, a sin sprung by your wanton fancy, and fill your hearts with the thoughts during prayer.
Why are our prayers not answered?
Satan strives to interrupt Christian in the act of prayer, when he can by no means keep him from it. He watches your motions and is at your heels wherever you turn to. If you think of any evil action, he is at your elbow to jog you on, or before you to remove every stone out of the way, so that you can carry out the evil action smoothly.
The Bible tells us in 1 Chronicles 21: 1-8, that David himself had some proud thoughts stirring him up to number the people; Satan took advantage, and worked with the idea which ripened into that sore which God lanced with sharp judgment as the loss of seventy thousand men. Now the devil is as skillful and ready at hand to disturb a holy action as to promote a wicked person.
When the sons of God came to present themselves before the Lord, Satan didn’t forget to be among them. He is always there when we worship and pray to God; indeed, he is there first before us and stays till the end. When he sees a vain thought, a sin sprung by your wanton fancy, he will help you to pursue those thoughts, and fill your heart with the thoughts while praying. Then your mouth is praying but heart is far away, and get disconnect from heaven. If our present thoughts in prayer is not of God, or not suitable to God and His glorious excellency, we pollute His name, and not honor it. We mock Him, not worship Him.
Sometimes he will prompt holy thoughts but impertinent, which, at another time, he would oppose with all his might, but now presents them, because we will welcome it into our heart thinking it will help during prayer. Though a good fruit, yet brought forth in a bad season. It disconnects our heart from heaven during prayer, thereby hindering our prayers.
You cannot hinder these roving thoughts from flying now and over your head, but surely you may do something that may prevent their settling.
1. Labor to poise your heart before you go to pray. Fill your heart with holy thoughts, the word of God daily.
2. Strive to keep your distance to the world, and that sovereignty which God has given you over in its profits and pleasures, or whatever else may prove a snare to you. All the creatures are man's servants. He needs to keep his heart at a holy distance from them, and maintains his lordship over them, not laying them in his bosom which God has put under his feet.
3. Observe and watch your thoughts during prayer. Sometimes our mind is off from prayer but we go on with lip-labor and takes no notice that our thoughts are gone astray.
4. Possess your heart with the awesomeness of God’s majesty and holiness. Pray as if you were taken up and presented before God sitting on His royal throne on high, with millions of millions of His glorious angels ministering to Him in heaven.
5. Don’t go in your own strength to pray, but commit yourself by faith to the conduct of the Spirit of God. God has promised to prepare our heart for this task.
Please let's take note of these points, and guide against any thoughts (good or bad) during prayer, so that our prayers can be answered speedily. God doesn't look at your mouth or body exercise during prayer, he looks at our heart. Our mouth and heart must say the same thing during prayer.
Wandering thoughts in prayer are like vagrants.
God bless you
(Outlines quoted from JOSEPH CARYL study- "EXPOSITION OF JOB with practical observation")