Sometimes well broke horses take advantage of a less trained rider. One classic trick of lesson horses and family horses is to walk along the rail or a fence surrounding an arena and scrape their riders toes along the wall, rail, or fence. This can be painful, annoying, or dangerous- especially if your leg were to catch in a gap in the rail.
Advanced riders could apply inside rein and outside leg with the appropriate seat cues to half pass away from the wall, but most horses know better than to try this trick with an advanced rider!
Inexperienced riders can solve the problem of the horse not moving off the rail by trying to prevent the horse from getting the opportunity to scrape your leg on the arena boundary. No one says you must work snug on the rail- asking your horse to go down the quarter line (halfway between the arena wall and the center line) puts a bigger buffer between your leg and the wall and also tells your horse “wake up! I’m in charge! Start listening as I give cues!”.
If your horse still finds a way to drift onto the rail, press your outside leg into the horse’s side. A horse should move off this cue, stepping to the inside. If the horse doesn’t move over away from the rail when asked by your outside leg, you can thump your leg to get the horses attention, or use a dressage whip to tap just behind your leg to reinforce your cue.