I get this too - thought it was just me/my family.
I never seem to actually 'dream' the answer, or know what it is ahead of time. It just seems obvious when I look at the code again later, and I totally rely on it now.
As others have said, actively thinking about the problem makes it less likely I'll solve it. Usually I just keep looking through my open issues, maybe writing a few lines, until I get that feeling I know how to do it.
Any other disciplines where this is 'a thing' - or is it just programming? I heard someone mention maths...