From: Get a verification code and sign in with two-factor authentication - Apple Support
A code is sent first to your trusted devices automatically:
"If you have a trusted device running iOS 9 and later, OS X El Capitan and later, iPadOS 13 and later, or watchOS 6 and later, the verification code is displayed automatically on your trusted devices."
If you don’t have a trusted device handy, you can choose to have a verification code sent to your trusted phone number as a text message or phone call.
1. Click "Didn't get a verification code" on the sign in screen.
2. Choose to have the code sent to your trusted phone number.
3. You'll get a text message or phone call from Apple with your verification code. This text message might include an additional domain validation line. This line includes the @ symbol, the website name, and your code (for example: @icloud.com #123456 %apple.com).
4. Enter the code on your other device to complete sign in.
"If you can’t receive a verification code on your trusted devices automatically, you can get one from Settings, even if your device is offline."
On a mobile device go to Settings > [your name] > Tap Password & Security > Get Verification Code.
On a Mac: Go to Apple menu > System Preferences [System Settings], then click Apple ID. Click Password & Security > Get Verification Code.
If you don't have, or cannot get access to, a trusted device, you can tap "Didn't get a verification code" and have it sent to a trusted number by text or voice.
Two-factor authentication for Apple ID - Apple Support
What if I use two-factor authentication on a device running older software?
"If you use two-factor authentication with devices running older OS versions—like an Apple TV (2nd or 3rd generation)—you might be asked to add your six-digit verification code to the end of your password when signing in. Get your verification code from a trusted device running iOS 9 and later or OS X El Capitan and later, or have it sent to your trusted phone number. Then type your password followed by the six-digit verification code directly into the password field."
Also:
Jan 2017 Community Specialist sterling_r post: How do I enter the verification number wi… - Apple Community - "On older software, if you are not given a box to enter the verification code, you can simply put it immediately after your password. Note that this would not require a space."