@DazzaF: My first thought when you mentioned a rattling sound was the Optical Image Stabilisation component, however this should only be audible if you shake the phone while the Camera app is closed. Is this the case?
Regarding the focus issue, have you tried tapping on the area of the viewfinder you want to focus on to see if you're able to improve the clarity of the picture?
I've had this issue in a previous phone as to where the focus of the camera wouldn't stabilise when taking a photo unless I gently shook the phone @DazzaF
I would suggest to let a Samsung Experience Store or Samsung Service Centre take a look at your phone.
Daily Driver > Samsung Galaxy s²² Ultra 256Gb in Phantom Black.
The advice I offer is my own and does not represent Samsung’s position.
I'm here to help.
This is a common issue with Samsung phones. Got the S20 Note ultra. This is not acceptable for such an expensive phone. Google it and you will see that many have the same issue.
I see, well that may explain your issue. But many have this issue randomly appear after a while and it doesn't seem like it was fixed in the S21 either: https://www.reddit.com/r/GalaxyS21/comments/nyxhkh/s21_ultra_main_camera_not_focusing/