Don't get discouraged, berate yourself or try to force your thoughts to stop. You won't be able to think your thoughts away. It will only make matters worse. When you catch your mind wandering, gently bring your focus back to your breath.
In the Zen Buddhist tradition, these thoughts are said to arise from monkey mind. Like monkeys in a jungle, going from tree to tree, our thoughts come out of nowhere, swinging here and there, out of control. When we quiet our thoughts we are said to be taming the monkey.
When we first start meditation, it is sufficient just to notice our wandering mind and gently return our thoughts to our breath. As we continue our practice we may begin to see patterns in our intruding thoughts. Is our mind planning, brooding, reliving, arguing, etc?
I find it very effective to name the monkey. When thoughts intrude on my meditation they are usually planning. Rather than being present with my breath, I am thinking about what I will do after I finish my meditation. When I notice this I gently think "Planning." This is my way of saying "Hello, planning monkey. I see you are here again."
Like children playing the game "Red Light/Green Light", these monkeys stop when they are noticed. Once they are named, they flee, allowing us to go back to our breath.
Don't try naming the monkey early in your meditation practice. You will probably find your mind struggling with itself over which monkey is here.
As you progress you will notice patterns of thought. You will also be able to 'catch' the monkey intruding earlier in the cycle. As this happens, when you can do so without putting a lot of thought into it, try thinking, "Oh, hi (anger, fear, planning, brooding,etc.) monkey. I see you are here." Watch how quickly he scurries, leaving you with your breath.
May you have have success taming your monkeys today.