You usually recover access by either using a trusted Apple device/phone number, or by starting Apple’s account recovery process.
Try these steps in order
1 - On the iPhone setup screen, enter your Apple ID and password.
2 - When it asks for the 2-factor verification code:
Choose “Didn’t get a verification code?”
Then choose one of of following
1- Send code to trusted phone number
2- Text me
3 - Call me
4 - Can’t use any of these options?
If you no longer have access to the trusted number or device, start official Apple Account Recovery here Apple Account Recovery
Apple may ask for your phone number linked to the Apple ID, device passcode,email access,waiting period for security verification
Important , Do not create a new Apple ID if your old purchases/photos/data are tied to the existing one.
If the phone still shows Activation Lock, you must recover the original Apple ID account to activate the device.
You can also contact official Apple Support directly here Apple Support