Can I suggest you take a sheet of blank paper draw a small round or square mark on it and preferably with the camera on a tripod try to see how far away from the Mark you made the red spot is before it stops locking the focus on the spot? You will soon see that you can be some distance away and that's why we get focus problems.
It is in the end a AUTO function and no one claims them to be perfect just like the AUTO exposure settings.
All is not lost however , there is a almost forgotten technique you can use, it is often as fast as the auto but does need good eyesight and to have the viewfinder diopter adjustment carefully set so the etched lines are absolutely sharp.
What you then do is use MANUAL focus