Why is my phone touching random buttons iPhone?

How do I stop my iPhone from pressing random buttons?

Change 3D or Haptic Touch sensitivity on your iPhone.
Go to Settings and tap Accessibility..
Tap Touch, then tap 3D & Haptic Touch. Depending on the device you have, you might see 3D Touch or Haptic Touch only.*.
Turn on the feature, then use the slider to select a sensitivity level..

How do I fix the ghost touch on my iPhone?

How to get rid of ghost touch on your iPhone.
Check Accessibility settings on your iPhone. ... .
Restart your iPhone. ... .
Stop using third-party accessories. ... .
Clean your screen. ... .
Update to the latest iOS. ... .
Update apps in App Store. ... .
Remove or replace your iPhone's screen protector. ... .
Reset iPhone Settings..