during periods of mind-wandering, regions of the brain’s default mode network were activated. Then when participants became aware of this mind-wandering, brain regions related to the detection of salient or relevant events came online. After that, areas of the executive brain network took over, re-directing and maintaining attention on the chosen object. And all of this occurred within 12 seconds around those button presses.
I'd be interested to see how sleep deprivation relates to this; I find my mind wanders easily when I haven't had enough sleep. Yet another reason to get more sleep to be happy and healthy.