Set up 2FA
…on iOS
On iOS 10.3 or later, open Settings and tap your name at the top of the opening page, then tap Password & Security > Turn On 2FA > Continue.
On iOS 9 up to 10.2, in Settings > iCloud, tap your Apple ID > Password & Security > Turn On 2FA > Continue.
…on macOS
In iCloud’s prefs, go to Account Details > Security > Turn On 2FA. If your Apple ID was created on a device running macOS 10.12.4 or iOS 10.3 or later, 2FA may already be enabled.
A Final check
On either system, you might need to answer your security questions. Check in Settings/ System Prefs that you’re still signed in to iCloud, and enter your Apple ID’s password if needed.