Two-factor authentication is an extra layer of security for your Apple ID designed to ensure that you’re the only person who can access your account, even if someone knows your password.
On an iPhone or iPad
Go to settings and click on your name → Click on Password & Security
Choose “Turn on Two-Factor Authentication”
On a Mac
Click on the apple icon in the upper left corner, and go to system preferences.
Choose “Apple ID” and go to “Password & security” under your name.