Everyone has heard that simple maxim:
"Do what works!" or "Do what works for you!"
Sometimes you want to draw a close bead on the rascal that is spouting that inanity, and let fly.
Maybe this will help.
If I am on a roll, in that magical groove, then I can write anywhere, while doing something like driving (I use a recorder - various kinds, including a clipboard) or watching a ball game, or while eating, or while listening to music, or in the quiet which is my preference.
But how to get on that roll, in that groove?
Try changing your venue. It it is quiet (too quiet) put some music on. Try different music.
If it is too noisy seek out a quiet place. Buy some noise canceling headphones, buy a white noise generator. Get a CD or device that produces those "going to sleep sounds." Waterfalls, brooks, meadows with birds, the sea shore with and without seabirds, etc.
If you don't like a section about going from A to B that you just wrote, and the rewrite isn't going well, just write a new way to get from A to B, or write something different.
Don't worry so much about everything fitting unless you are in the mood to make things fit and "it is working."
If nothing works, if no change seems to be effective, if you are getting really frustrated, do something else. Another story, watch a movie, go to bed but with a recorder or clipboard by your bed.