The brain is continually tweaking these connections and it uses sleep to make adjustments. During sleep, what you learned during waking hours is contextualized and adjusted to fit everything you already know. All this happens below the level of conscious thought.
When I write a story, I have to think of how I'm going to get from where I am to the next point. It can be as easy as putting Mycroft Holmes on horseback with a couple sepoys and sending him into the countryside of Kashmir. Or it can be as tough as figuring out how a bunch of boffins can miss the solution our young adult protagonist finds at the climax of your story.
He spoke of how he went about engaging his brain to write:
"I took the family alarm clock and went into the spare bedroom that night, and set it for an hour and a half. And thereafter, when I was working on a story, I would waken myself every hour and a half, through the night--force myself to wake up, think of the story, try to solve it, and even as I was thinking about it I would fall back asleep. And in the morning, there would be a solution, for that particular story problem. Now, that's penetrating the subconscious, in my opinion. It's penetrating it in a way that I don't think they'll be able to do any better, thirty centuries from now."
A. E. Van Vogt was characterized by Damon Knight as a pigmy at a giant's keyboard. If this is so, then he was one amazing pigmy.