You may have a bad digitizer. Once you unlock your phone, make sure all the keys are working properly. If they don't, make an appointment at the Genius Bar or authorized service center to have it replaced.
If you forgot the passcode on your iPhone, or your iPhone is disabled or unavailable -
Click on the link for instructions on how to reset your passcode without a computer if you have iOS 15.2 or higher.
If you forgot your iPhone, iPad, or Apple Vision Pro passcode, reset your device without a computer - Apple Support
Click on the link for instructions on how to reset your passcode using a computer.
Use a computer to reset your iPhone and your passcode - Apple Support
Make an appointment at the Genius Bar to have it diagnosed.
Genius Bar Reservation and Apple Support Options - Apple