It is inevitable that your attention will wander. I have never met anyone that can always maintain complete focus every single time they meditate. A wandering mind is perfectly normal and okay. Like all skills, it takes time and practice to maintain focus and attention.
If you become aware that your mind has wandered, simply allow those thoughts to drift through your mind and away and return your attention to the meditation. Always be gentle with yourself.
Some people I have taught would get frustrated and angry with themselves whenever their mind wandered. Although this is quite a natural response for some, it is quite counterproductive to meditating.
Think of your mind as a child. If a child is not paying attention and off having its own fun and you get frustrated and angry, there’s a good chance that child is going to dig its heels in and resist anything you have to say and you’ll probably end up in a screaming match that neither side wins. However, if you get the child’s attention with love, kindness and compassion, the child will respond and listen to what you want.
The mind works the same way. If you try and force it to do something, there’s a good chance that it never will. However if you simply guide it to what you want, the mind will easily follow.