Perhaps the motor function of writing is part of this. I notice similar effects while walking and thinking too, though not always in the same way. It seems like the mind needs to be given a chance to meander, almost as if when the body is busy doing something else (writing, walking) it has a chance to actually not worry about what to do next and instead just relax on a thought and potentially discover something new about it. This feels in some way similar to
Diffuse Thinking or
Benefits of walking