That's Weird, I've never had to do that. I can just login to Google with my username/password. If it doesn't recognize the device it just pushes a notification of the sign in to my phone
It also has nothing to do with the YouTube app, and there is no code I have to enter anywhere.
I've never had any form of 2FA on my Google account.
I believe you, I'm extremely surprised I didn't see this considering I've logged in from all sorts of sketchy IPs/VPNs.