Based on: Get a verification code and sign in with two-factor authentication - Apple Support
A code is sent first to your trusted devices (some other Apple computer or Apple mobile device signed in with your account) automatically. If you have a trusted device running iOS 9 and later, OS X El Capitan and later, iPadOS 13 and later, or WatchOS 6 and later, the verification code is displayed automatically on your trusted devices.
It is a good idea to have more than one trusted number.
If you had set up a recovery contact, read Help a friend or family member as their account recovery contact - Apple Support
If you see. “Verification codes can't be sent to this phone number at this time. Please try again later,”:
1) Use this link to check the status of Apple’s various services and servers —>
Apple - Support - System Status
2) Remove entirely any VPN you are using.
3) Wait a few hours and try again. Maybe it really does mean not at this particular time.
From: Suddenly not getting texts for two factor… - Apple Community
Q: Suddenly not getting texts for two factor authentication on iPhone
A: Reset network settings:
Go to Settings > General > Transfer or Reset iPhone > Reset > Reset Network Settings
Contact Apple. Refer to this page for Apple Support for different countries ➔
Choose your country or region - Official Apple Support
Select your country (if you do not see your country, also look for "other" in regions; e.g., "Other Africa"), then "Choose a product". Click the "show" item under each category for more selections. If you don't see one that handles your issue then keep experimenting with selections until you reach one that gets you a chat session or a telephone call and get the representative to redirect you.
If after all that you still can’t receive verification codes, you can request account recovery to regain access to your account [ How to use account recovery when you can’t reset your Apple Account password - Apple Support ]. Account recovery might take a few days or longer, depending on the specific account information you can provide to verify your identity.