There are so many different ways in which the image can be distorted. Sometimes it's photographer's fault. If you can't keep the camera steady then you will get blurs. Sometimes it's the camera's fault. In high ISOs, you might get really grainy images that just don't look very good, or maybe some pixels on the sensor are dead so the image looks dusty.
But sometimes it's the lens' fault, and if you've been getting some funny looking pictures and you want to know why, well if you've used a tripod, not damaged the sensor and kept it clean, it might be because of the lens. The problem with lenses is how complicated they can be. In a single camera lens there are several lens elements inside. Each of them work to bend light a certain way and each one has to be very precise, otherwise you get a little distortion.
Chromatic Aberration Lenses are pretty good at bending, refracting and even splitting lights into the different coloured wavelengths. Think of Newton and his prism showing the rainbow. In camera lenses, that splitting shouldn't happen; the light should be refracted but not split up. But it can happen. On images it looks like the objects are fringed with different colours like red or green or purple. Some lenses boast special elements that eliminate this problem, and it's less likely to appear if you photograph using bigger apertures.
Vignetting
If the picture comes out with darkened or blackened corners while the image in the middle is fine, that's vignetting. Sometimes something is blocking the light, like a lens hood, sometimes the angle of the light is wrong so the outer edges are dark or sometimes the lens elements just don't compliment each other well so the brightness decreases on the edges. Vignetting isn't ALL bad, sometimes people add it into photos in post processing for added effect, but you don't really want it in every photo.
Low contrast
You can blame low contrast images on a variety of different things like sensor quality or maybe it just looks that way on your computer screen. Very occasionally you can blame the lens. With so many lens elements, occasionally the lens can't differentiate between different tones. The image comes out looking a little hazy, as if there was a film of smoke in front of the lens. Occasionally it's not the lens that's the issue; it's the angle of sunlight which means a nice lens hood would solve this problem. Low contrast is pretty easy to fix on photoshop.
Distortion Have you ever seen a picture where the image is warped a little? Like buildings bending inwards, or foreheads that were bulbous. That's barrel distortion, and is most often associated with fish-eye lens, because the effect is deliberate. It becomes a bit of a problem when you have zoom lenses and you DON'T want the edges to bow inwards as if you are looking at the world through a fishbowl. It's quite common in low quality lenses and if it's minor you could just fix the problem in photoshop.
When it comes to distorted or messed up photographs, it's because of your lenses, but the best way to avoid lens distortion, is to not buy a lens that has this problem. Sometimes even the best manufacturers produce a lens that can distort the image before it hits the sensor, because with so many elements that need the upmost precision mistakes do happen. Read reviews, and if you can, try out lenses before investing in them. But if you do have a lens that isn’t quite perfect it’s not a big deal, either the errors are minimal, or they can be fixed in photoshop.