Try these few methods :
Try clearing the storage and cache in app settings. Then restart the phone, see if the problem resolves or not.
Boot the phone in safe mode. Press and Hold power button, press and hold power off and reboot to safe mode. Try the camera app in safe mode, check if the problem resolves or not. If it's working fine, then there's some 3rd party app installed on your phone might be causing the issue.
If you tried all the steps above and the problem persist, it might be hardware related issue.