When I was in a psychiatric ward there was a girl two beds away from me that used to do this. She’d do it for hours, just sitting there and rocking.
One day, I asked her why she did it.
“Because it takes me away”
“Away from what?”
When i started doing this on one of my therapy sessions, my shrink told me to keep doing that, because its a way to calm yourself.