There's multiple kinds of "locking" on devices. Click on the links below to find instructions on how to deal with your specific situation:
1) iCloud: Activation Lock - Activation Lock for iPhone, iPad, and iPod touch - Apple Support - This is a security feature so only legitimate (e.g., not stolen) use of devices is possible. Read this support article about how to remove Activation Lock --> How to remove Activation Lock - Apple Support - If an activation lock was put on a device, only the owner of the account that applied the lock can remove it. Get them to remove it or return the item for a refund. If you are the owner, see the part at the end about asking Apple to reset the device.
2) Device lock: If you forgot the passcode for your iPhone, iPad, or iPod touch, or your device is disabled, read this support article if you are using iOS or iPadOS 15.2 or higher --> If you see an iPhone or iPad unavailable message or Security Lockout screen - Apple Support or here if you do not meet the criteria for the previous method--> If you forgot your iPhone passcode - Apple Support
3) Carrier lock: Read this article about how to unlock your iPhone for use with a different carrier. --> How to unlock your iPhone for use with a different carrier - Apple Support Only some carriers offer the ability to unlock iPhone for use on any carrier. Follow the instructions in this article to unlock your iPhone. If ATT has this locked to their system, only they can unlock it. You will have to resolve it with them.