I have a Welsh Sec A gelding who developed that kind of behaviour when he was about 6. He has been gelded since he was a yearling. We found it related to when the mares he was turned out with were in season. The only solution we found was only to turn him out with other geldings. He is fine when handled and ridden including on the lead stood in line next to in season mares. I guess that doesn't help but it was the only solution we could find.