This doesn't help for Gmail. I moved to a different part of the country and I have a spam email account that isn't connected to a phone or second email. Even with the right password, it wouldn't let me log in because I was trying to sign in from a different location and no secondary way to authenticate.
Luckily it was a spam email so it was just annoying to recreate some accounts I used for that email, but yeah ve warned.
Yeah, GMail's security is terrible in that regard and having learned about their geolocation policies I basically never use them for anything now.
If you're in the Apple ecosystem, iCloud is actually pretty good. Lets you generate and manage random email addresses for different things too, so you can give to a nonprofit or a campaign and not be forever spammed for donations thereafter. Plus, their authorization system is device-based so assuming you don't lose access to all your devices, you can get in pretty easily even from webmail in a different location.
You can go into your account and under two-step, generate a one-time code. Store that code somewhere secure, like a note in your password manager if you trust it with both steps, and you can do it.
Pretty sure Google authenticator will have something equivalent but likely more secure, but haven't used it.
It's why i've took to writing down my passwords in an old notebook. If my home ever gets robbed, that bundle of paper is totally staying behind and saving my skin