See if anything here helps. If necessary, you can use account recovery as explained in the link at bottom of the article.
Verification code - how to get one and sign in with two-factor authentication. *
If you can get a code and sign in, you need to change/add the number on your Apple ID. Look in the Security section when signed in online. You may have to add the new number before you can remove the old number. After the change, allow up to 24 hours for the change to sync. Before trying to make the change, sign out of Messages/FaceTime on all devices/computers.
Apple ID - Manage
Then sign in and see if you can recover your contacts. If syncing contacts with iCloud, try Settings/Your Name/iCloud and slide off syncing. Wait a few minutes and then slide syncing on. Allow time for syncing to occur. The photos sync is extremely slow. It could take several days or more for the photos to sync.
Last resort - have you tried signing out of iCloud, restarting the device, and then signing back in?
See the Apple Support article below.
Contacts, Calendars, or Reminders - Get help using iCloud.