The correct answers have already been covered. For a simple lens, the surface for which the image is in sharp focus is indeed a curved surface. The inside of your eyeball, with its curved surface covered in biological pixel receptors, is a great solution to the problem of how to keep things in focus over a large angular region.
Unfortunately, film cameras require flat focal planes because the glass plane is flat. You could, I suppose, try to make a curved glass film plane, but you’d want it made very precisely. And then you couldn’t easily see the image. Or make prints, or whatever. The same thing carries through to CCDs and other solid-state imaging surfaces. They’re muxch easier to make accurately and tightly packed when they’re flat. Fortunately, all the effort going into flat-field cameras means that there’s plenty of technology experience in majking thingsd that produce planar images. (But I firmly believe that, in some future of precision nonplanar micromanufacturing, someone’s going to start building cameras with curved image planes, like eyeballs.)
The easiest way to keep everything in focus over a plane is to make your aperture really small, “stopping it down” as small as you can. This increases your depth of field, as noted, and keeps everything in focus over the whole rangeI the extreme case of a pinhole camera, the image is always in focus, regardless of its distance from the pinhole, and you don’t even need a lens. The drawback is that you don’t get much light through the pinhole.
So if you want a lot of light through your lens, you need a large aperture, and now, if your lens is a simple one with only one element, your image surface is curved, so a flat film plane gets fuzzy as you get farther from thecenter.
Again, as noted above, you use a lens with more than one element, adjusting distances, curvatures, and lens materials so that you introduce what are, from the point of view of the ideal curved image surface, aberrations. But you design these aberrations so that they bring that image into good focus in a flat image plane. This really isn’t a trivial problem, and it gets harder as your aperture gets larger (to let in more light) and you want to fix things over a larger film area and have it work throughout the visible spectrum. Each surface, thickness, and glass type adds another variable you can tweak to get the result correct for all angles of incidence and for all points on the film plane. Nowadays you can also use aspheric surfaces (like that Schmidt Corrector Plate mentioned above) and gradient-index optics as additional variables, but it’s still cheapest and easiest if you can design something that uses standard glass types and all-spherical surfaces. That’s a lot of number crunching, and it used to be done by hand. Nowadays, optical design software is invariably used. These can be set up to perform outrageous numbers of calculations and to automatically vary the lens parameters to optimize your solution for a really good flat-field weide=aperture lens. Building it will probably be the longest and most expensive part.