Hey, Welcome to Samsung Members!
We recommend following these steps:
1. Go to Settings > Check for software updates > Download and install.
2. Go to the Galaxy Store app > Menu > Updates > Update All
3. Go to the Play Store > Tap your Google Account ID at the top > Manage apps and device > Update all.
4. Go to Settings > Apps > Camera > Tap Camera settings > Reset settings > Reset.
5. Go to Settings > Apps > Camera > Tap Storage> Clear Cache & Clear Data.
If the phenomenon continues we will be happy to receive another inquiry together with a fresh system log right after the phenomenon occurs and an accurate description of the case so we can assist.
To attach a system log go to Samsung Members > 'Get Help' > select the "Error Reports" category > select the appropriate topic and then describe the phenomenon in detail, at the bottom of the page and make sure that sending the system log is marked V.
I would also recommend attaching a screenshot shows the phenomenon so that we can help.
Unfortunetly you are not the first with this issue. It's almost always fixed with replacement of the camera module 😞
The easy check is exactly what I said. Shake the device to get the lens unstuck then take picture. If focus suddenly works, you have a stuck lens problem. Unfortunetly it's fixed only with hardware replacement. But of course, get it checked by a specialist to make sure it's this problem. Sorry mate.