The way you deal with it depends on the type of meditation. But for beginners, whether you cultivate Samata or Vipassana does not make so much difference in that respect.
It is usually advised to beginners to emphasize the application of alertness. Alertness is like a spy: it is a mind that check where you find yourself, how you are doing, whether you still focus on your object and in what way. The more alert you are, the less inattentive you are. When you are not alert at all, you wander without noticing that you are wandering. In other words, it is advised not to try to hold onto the object very tight, but to often check how you are doing. In the beginning, you will lose your object of concentration a great deal, so you will have to realize that you lost your object as often. This is bound to happen. You can not simply set out to stay with your object without loosing it in the beginning, for that would not be realistic. So, your goal as a beginner ought to be something like "I will notice every time I lost my object", "I will not wander for too long", "I will not be inattentive and dive into objects mindlessly" rather than "I will hold onto my object so tight I will never ever loose it." It is a way of saying that on the outset, the cultivation of alertness is more important that that of mindfulness.
There are exercises you can engage in, that will show you how "funny" your mind is. Hopefully they will help you find a way to cultivate concentration. For instance, sit for half an hour in a meditation posture, and tell yourself "Whatever happens, wherever my mind goes, it's fine by me. I will not interfere, I will not judge, I will not try to change its course. I will simply step back and observe." When you do that, your mind behaves surprisingly well. But as soon as you stop observing it, it goes wild. There is an idiom that goes "When the cat's away, the mice will play".
On the opposite side, you can try to not think of an elephant for a couple of minutes. Set out to purposely not think of an elephant, for two minutes. Try very hard. The more you purposely try not to think of an elephant, the more you think of it. In fact, once, I received this instruction "not to think of pizza for two minutes", and I managed quiet well when, instead of setting out to not think of a pizza, I told myself "It's okay if you do. Just observe your mind." Why? It is because when you do that, you take a step back, you disengage from the external object, you do not dive into it. Whereas when you plan to not think of this or that, you will tend to dive into whatever you are not supposed to think of. It shows you that, if you lost your object of concentration because you were thinking of something else, it will not get better if you are forceful and beat yourself up, and regret loosing your object, etc.
Of course, you mind wanders because it lacks habituation. Actually, it's used to jump from one thing to the next. It's good news: there is nothing that doesn't get easier through training. Another thing is that your mind wanders because you do not see things the way they are. That is why, even if you want to cultivate Samata, it is good to sometimes engage in analytical meditation on death, impermanence, suffering, and so forth. Because this will support your non-attachment, non-anger, etc. Not attached, your mind will wander less. Not angry or frustrated, when you will loose your object, you will not want to be separated from your "failure" so badly that it will hinder your concentration.