See the article Two-step verification for Apple ID - Apple Support
What if I no longer have access to any of my trusted devices?
If you can't access any of your trusted devices, you can still access your account using your password and Recovery Key, or with your password and SMS-capable phone number. You should then verify a new trusted device as soon as possible using the steps below.
- Go to your Apple ID account page and enter your Apple ID and password.
- On the Verify your Identity screen, select "Can't access your trusted devices?".
- In the pop-up window, enter your Recovery Key.
- Go to the Security section and click Edit.
Remove the device you no longer wish to use to verify your identity. If you have additional devices with Find My [device] enabled, you can verify them as trusted devices. You can also add additional trusted phone numbers.