As you've seen, a lens can only bring objects at a single distance from the camera into sharp focus. But if you look at photographs, you can see a considerable area of the scene from near to far that appears sharp. Even though theoretically only one narrow plane is critically sharp, other parts of the scene in front of and behind the most sharply focused plane appear acceptably sharp.
Read more and learn about it!