Two-factor authentication
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 else 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 website. If you create a new Apple ID on a device with iOS 13.4, iPadOS 13.4, macOS 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 the Apple ID account website. In the Security section, click Edit, then click 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 are 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 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.
As extra protection for your Apple ID against phishing attacks, you can use a physical security key instead of a verification code. See the Apple Support article About security keys for Apple ID.
See the Apple Support article Two-factor authentication for Apple ID.