Lots of interesting advice with continual repetition being one that can work if you're wanting to plug into a "finger memory" style of playing.
However, if I'm understanding you, there are tunes you know, but they drop out where you could otherwise potentially improvise what you hear in your head. I'm guessing that your ability to hear things to improvise = hearing harmonies and melodic lines that fit the structure. So possibly it's not the structure and it's not an issue of coordinating fingers to what you hear.
I'm guessing... you've got two conflicting modes of mental pathways. If you want to play known/recognizable tunes as an improvisor, then you need to strengthen that pathway and not interrupt your flow by "externalizing" and asking yourself "how does that go?" To play any tune as an improvisor means leaving off visualizing dots, remembering words, or anything else other than being able to sing the tune completely trough without external inputs. If you can sing it, then you can definitely hear it and can physically execute it.
So advice wise, I'm skipping the learn the tune part except for tunes you can't yet sing. One of the shortest and best bits of advice came from Grumps. Put on music (I use the radio) and make it something you've never heard before, NOT the same old tunes you've played, and play along. Use Classical, rock, smooth, reggae, ethnic... anything. This is then you reinforcing your ears to hands pathway. It requires that you are NEVER thinking about notes, intervals, or even the key you're playing in. It's reinforcing the ears to hands pathway. It means you hear what's happening, and can also anticipate where it's going.
The happy birthday (or any simple tune) is also a good exercise, however the twist is to NOT assign a key. Use a random start note. That way you have to hear all that comes next and obviously play it WITHOUT interpreting it and trying to "translate" what you would have played in another key.
There's some science behind this which becomes more relevant as we get older. Our brains are not as plastic as children. The majority are visual learners. Almost all teaching is based on their needs. Thus teaching that emphasizes "translating" what is audio information into visual constructs or information that describes what to play without hearing the music. This does work for them, however if you're a audio learner it's potentially an impediment as you're being asked to translate something you can already hear and intuitively understand.
Unfortunately being an audio learner doesn't mean that you can pick up any instrument and play it fluently. It takes a lot of practice to coordinate what you hear to fingers, breath, embouchure, etc. The only natural instrument is our voice.
Understanding what you have played is also a good idea, knowing keys, intervals, chords, and theory, however that's primarily useful in being able to communicate with other musicians and not the mode of thinking when playing as an ear player. With the exception of the "Suzuki method" of teaching, there is no training for auditory learners. The odd thing though is that the Suzuki method mainly works for very young children who have "plastic" brains and can learn music as one learns a language, imitation through hearing, and not visually. The rest of us auditory types are left to our own devices. Many/most follow a visual/academic path with some eventually finding their way back to hearing what they will play instead of translating.
Most of the exercises one needs to develop technique, breath, embouchure, etc. will be the same for visual and auditory learners. However the way one plays most effectively potentially has a divide between those who are primarily visual learners compared to auditory.