Maybe check the saddle fitting or flies could be bothering her
This happend to my ponies and it turned out her saddle didn't fit so I got a riser and shes stopped now
Definitely check her spine/SI. Could be sore feet but that's less likely. Saddle positioning will do that every time so make sure that is sitting right.
Could be chiropractic. She could be out. There could be saddle fit problems. Possible lameness, or teeth problems
Have her vet checked but otherwise the best way to stop it is to ride it out in most cases
Maybe lunge her and call the vet for a check yp
there's also a possibility that she just had some energy. What helps when my pony does that is just a quick lunge!
I'd get her back checked :) And check the saddle fit too.