My horse does this.. now there's two ways I personally go about it.
If he swings them towards me, he gets a cupped hand whap. It makes a lot of noise and doesn't hurt and he swings away from me. I do this because it's dangerous behavior swinging his butt at me!
Now if my horse swings away from the mounting block, I move the mounting block and keep prompting him to do a turn on the forehand, then the haunches, then I back him up and then send him forward. This is usually enough to get his head spinning with the thought of "WOAH where did all this work come from?" So he tries again, and I repeat in a different order. Sometimes I go on the other end and make him do a sidepass or turn on the forehand until he learns his lesson.
So long as you end on a forward note and make sure the mare doesn't anticipate your next move. If she starts turning around because you move sides or towards her hip when you didn't ask, then undo the move she just did.
What also helps is mounting with a pole on the side she swings out to, it's a lot more work to lift and get over.
There's lots of ways to fix it.. just don't do something out of anger, always focus on teaching wrong answer vs. right answer.
You could also stand on the mounting block and direct her via inside rein where to go. Don't stop her until she's standing near the mounting block to where you can get on.
Now if she's nervous about the block, it doesn't hurt to desensitize her to it.
Good luck :)