Immersing yourself in a problem for a long time often establishes a number of assumptions in your brain about how said problem should be solved. When stuck, withdrawal from the direct effort of work can free up some of these assumptions, letting your mind entertain other possible approaches.