Some horses are strange.
My new to me oldie has strange poop habits. His water, feed and hay are all stationed on the front wall of his stall. When he poops, he turns his front end away from the front wall swings his back end towards the front wall and poops. So he lines the floor near the front wall with manure. He’s in a 15x20 stall so he has plenty of room to stay tidy. He just doesn’t. He walks to the back of the stall to pee, so I don’t think it’s a lameness issue (though the old guy isn’t what I’d call sound).
I had a hony mare that would poop in the water trough in the field in times of distress. Distress could be: location move, herd change, horse show the weekend before, high heat in summer, lots of bugs out, being put on a diet (she was a chunky thing), etc. It was a giant PITA. Interestingly, said mare didn’t really express her anxiety / discomfort in any other way.