I occasionally walk a few blocks when I'm mentally stuck on something. Usually that's all it takes. I find that going for a walk minimizes external demands and maximizes the mental resources that can be turned inward. It also provides a nominal purpose that allows my mind to abandon its direction and wander out of whatever cul-de-sac it was stuck in.
When I was in high school and college, though, I used to drive to think. It was partly to do with growing up in Texas (a big, spread-out state with lots of straight, empty highways) and also partly to do with privacy. If I wanted privacy, I would go out on the highway and drive. Living with parents, and later with roommates, a car was the only place where I knew that I wouldn't be bothered. In a small town, walking means making yourself conspicuous, which isn't conducive to contemplation. You have to be in a dense city or a rural area to achieve solitude through walking.
Given that driving used to serve the same purpose for me, I wonder if the physical effects of walking are important. For me, the most important factor was suspending the constant vigilance of being around other people. Always knowing you could be interrupted, knowing you might need to put on a mask at a moment's notice, how can you really think? Walking and driving require a very low level of engagement with the outside world, but some engagement, which intermittently rises and falls as you encounter interesting sights or an occasional challenge such as a puddle to walk around, another car on the road that must be paid attention to, or a choice of going right or left. (Driving in the city usually doesn't work. Safety demands too much attention.) If I were to name the most important factors, I would include solitude, freedom from vigilance, and occasional non-threatening interruptions of one's train of thought.