Hi imaginekp,
To help troubleshoot, test the behavior after restarting your iPhone and after removing any case that is on the device. Additionally, ensure your iPhone has at least 1GB of available storage, as storage can affect performance of iPhone: About iOS or iPadOS performance on your iPhone, iPad, or iPod touch - Apple Support
You can check your device's storage in Settings > General > [Device] Storage. For best performance, try to maintain at least 1GB of free space. If your available storage is consistently less than 1GB, your device might slow down as iOS repeatedly makes room for more content.
If the issue persists, reach out to Apple Support directly for assistance with diagnosing the camera. You can see that outlined here: If the camera or flash on your iPhone, iPad, or iPod touch isn't working - Apple Support
Contact Apple Support
If the camera or flash still isn't working properly, contact Apple Support to discuss service options.
Kind regards.