Every time I right-click an object in SSMS 2016 and click Script Object As > CREATE To > New Query Editor Window, I get the prompt below. Not sure if I changed a setting or what, but was hoping someone knew how to make it so it doesn't prompt to open a new connection each time.
I was able to reproduce the problem you're encountering.
Originally, I wasn't being prompted like you are being prompted. There is a button just to the right of New Query that invokes the Database Engine Query. This button would be very easy to click because it's close the the New Query button
This brings up the connection dialog box you are experiencing. The problem is, once you click this button, you will continually be prompted for a connection until you exit out of SSMS and come back in (at least, that is how I corrected the problem).