Personally, if my mind wonders during sex it's cuz I am not really that into it.
Sometimes I worry that someone might hear my vibrator but then I just reassure myself that I don't care if they hear, maybe it'll incite the neighbor to jack off imagining me masturbating
For me it's just changing what I think about the situation. As soon as I become aware that I am not focused on my/my partners pleasure I clear my mind and focus on the pleasure. Kind of like meditation.
The only thing I can suggest is to refocus. You could play some music maybe that might help. Maybe your mind wonders bcs there hasn't been enough foreplay therefore explaining your lack of relaxing during the experience. Set the atmosphere with candles or anything you like.
If it is a recurring pattern of thought that enters your mind such as tasks/chores that need to be done, make sure they are done before or just settle in your mind before sexual activities that they can be done later so that the thoughts don't interfere. Or before you have sexual activities meditate, do breathing techniques to clear your mind. Tell yourself that your thoughts can invade your head only afterwards.
Well, thats all I can think of, good luck!