My six year old does the same thing. It is like a "thing to do" for him. He calls it "thinking".

When he wants to entertain himself he'll say "I'm going to go think" and head off to go lope around somewhere in a repetitive loop.

He thinks about all kinds of things -movies, books, meaning of life, how to create comfortable armor for his chickens so they are protected from predators smile.

We've been talking about not "thinking" in public.