My S21 Ultra has had the same problem for about a year now
@LvR88. Others have the same problem as this subject has been posted often on this forum. The workaround I have is that, before shooting at 1x, I select 10x and let that focus before dropping to 3x and letting that focus, before then dropping to 1x which will always be bang in focus then. I do the same for video.
All this is a pain I know, and sadly there will be no software cure for this as a replacement camera module is the only remedy. This may not be what you want to hear. It certainly wasn't what I wanted to hear when I first researched the problem. I hope my workaround can at least give you some relief and prove helpful.