Your camera probably chooses where to focus.
This feature is often called Automatic Focus Area Selection.
If you’re happy with the results, don’t change the setting.
However, you may find the camera doesn’t always focus where you want it to focus.
If so, consider changing the setting to focusing only in the middle of the viewfinder.
If your camera is set to focus in the middle area of the viewfinder, and you're photographing something that's NOT in the middle, the focus will be off.
Let’s say you’re photographing twins.
Your camera will focus on the background between the twins.
To focus on the twins, point the center of the viewfinder at one of the twins.
Press the shutter release to focus, and keep the shutter release depressed.
The focus remains locked as long as you keep the shutter release depressed.
Then, with the focus locked in, move your camera so both twins are in the frame.
Depress the shutter release fully.
You can set your camera to focus four ways.
Of course, camera manufacturers may call these focusing methods by different names than those below.
Check your instruction manual.
You have to focus by turning the lens.
You may need to use manual focus if the light is very dim, making it difficult for autofocus to function well.