Broken touchscreen ... real sentasive to use. Sometimes works fine... then it won't work
Has the phone ever been dropped or are the water sensors tripped ?
Check your phones firmware is up to date.
Put the phone in Safe Mode which disables any downloaded apps and leaves the stock ones Live which can help to highlight if a rogue app is causing this.
If the issue stops in Safe Mode then come out of Safe Mode and start deleting your most recent apps one at a time until the issue stops.
If that or a soft reboot by turning the phone Off and On does not help then a Samsung Service Centre should be able to help.
Daily Driver > Samsung Galaxy s²³ Ultra 512Gb in Phantom Black.The advice I offer is my own and does not represent Samsung’s position. I'm here to help. " This is the way. "