If you're sure that nothing (cover, screen protector, dirt) is obstructing your touch screen, try a forced restart of your 12, using these gestures:
Press and quickly release the volume up button, press and quickly release the volume down button, then press and hold the side (power) button. Only when the Apple logo appears (it might take 10-20 seconds), release that button (ignore all other screens that might appear, the one with the "slider" to turn the device off included).
If the issue persists, it might be a hardware (battery? screen? other internal component?) glitch but we, just users like you, cannot diagnose that issue remotely, sorry.
I suggest that you make an appointment (*) and have your device inspected at an Apple Store or AASP (Apple Authorized Service Provider) among this list:--> Apple – Location Selector. After checking it out, they'll give you all the available options.
Regards
Giulio
(*) You can do it: