A wavering attention causes the mind to generate distracting thoughts. If attention is rock solid, distracting thoughts will not be generated.
On the other hand, thoughts themselves cause attention to waver around, compounding the effect of new thoughts being generated. Other things that cause attention to waver are sensations in the body. Usually an unpleasant or sudden sensation will yank attention towards itself, and this yank will result in new thoughts.
Attention is often focussed on an imagination of a quantity rather than the quantity itself. For example, close your eyes and try to focus your attention on the back of your head. You will notice that some image of the back of your head will pop up in your mind, mixed with actual sensations happening on the back of your head. Your attention will most likely be fixed on this image of the back of your head, even though you have never seen the back of your head with your own eyes.
So what’s the solution? Let thoughts happen, let attention waver, let images crop up. In the beginning, it is nigh impossible to prevent attention from being yanked around, and images to be generated in the head. But be aware. Be aware that these things are happening. Don’t try to fight the thoughts and images that arise in your mind — they are a byproduct of the nature of the mind itself. Let the mind do its thing without hinderance, but do not get carried away with it. Be aware that it is the mind doing its thing. Every time the awareness arises that the mind has carried attention away with it, bring the attention back to its focus. It is this awareness that you must practice, rather than the suppression of the mind.
As time passes, and the practice of awareness grows, the mind will follow suit. When the mind has worked through all the thoughts and images that it wanted to generate, it will go and sit quietly in the corner, waiting for attention to call for it willingly.
But this will take time, and patience, lots of patience. So keep working.