Two-factor authentication is an extra layer of security for your Apple ID designed to ensure that you are the only person who can access your account, even if someone knows your password.
You can turn on two-factor authentication and manage your trusted devices and phone numbers by signing in to your Apple ID account page. If you create a new Apple ID on a device with iOS 13.4, iPadOS 13.4, macOS Catalina 10.15.4, or later, your account automatically uses two-factor authentication.
Enrol in two-factor authentication
If your account meets all the requirements for two-factor authentication, you are prompted to turn it on when you first use your device.
Important: If you are using two-step verification, you must turn it off before you can turn on two-factor authentication. To do so, sign in to your Apple ID account page. In the Security section, tap Edit, then tap Turn Off Two-Step Verification. You are asked to create new security questions and verify your date of birth. You should receive an email confirming that two-step verification for your Apple ID is turned off.
Use two-factor authentication
After you have enrolled, when you enter your Apple ID and password for the first time on a new device, you are asked to verify your identity with a six-digit verification code. This code is displayed automatically on your other devices or sent to a phone number that you trust. Just enter the code to sign in and access your information on your new device.
You will not be asked for a verification code again on that device unless you sign out of your device completely, erase your device or need to change your password for security reasons.
See the Apple Support article Two-factor authentication for Apple ID.