Anecdotal: a friend of mine used to play some casual mobile game for quite some time (Candy Crush or something), she told me once that when she was giving birth she involuntarily started to "play" the game in her mind when the stress and pain became too strong, she said it helped her both to distant herself and to focus. :)
Honestly it’s probably the same mechanism as dreaming. Just your brain training itself too hard while you’re still awake.
there's no score, no deadlines, and no punishment for missing things in the game, so it's a very relaxing game for me. some 'days' in the game i'd get up, water my plants, and just go back to sleep because i didn't feel like doing anything.
other people naturally like to min-max, though, and the game certainly allows you to do that. there's people who'll make farms that are entirely optimized for maximum gold production; there's practically nothing to do with that much gold but seeing the numbers go up is what they enjoy.