Practice meditation and try to be stress free and focus on the present and bring your attention back.
Find your goals or to-do list and try to prioritize your goals accordingly to maintain focus and to reduce mind wandering.
Take regular but short breaks as they can help you to recharge and relax your mind.
While working try to focus on one thing only and stay away from distractions like social media, phones, etc.
Work on only one single task at a time, as multitasking can increase your mind wandering.
Regular physical activity like walking, running, or swimming can help you out with a wandering mind, and help to increase your focus.
Engaging yourself in creative activities like doodling can help you to release tension and promote overall productivity.