Your mattress can harbor odors: mildew, body odor, chemical, or other "accident" smells. Depending on the type of stain and odor, usually you can air out your mattress for an easy fix. For stronger soaked in odors and stains, cleaning and airing usually can save you from buying a whole new mattress.
Before you start: its a good idea to remember that you should never apply liquid directly onto your mattress lest it soak in to the inner mattress and start to mold. Its also a good idea to start any mattress cleaning project when you can afford to leave it out of the bed frame to dry for 24 hours. Finally, keep direct heat sources (like hair dryers) away from mattress. These can "bake" in dirt and odors, and make a smelly mess.
The first step to eliminating odor is to first give your mattress a good once over with the vacuum. This will eliminate any surface dirt and avoid it from being rubbed or baked in. In everyday situations, a good vacuum and flipping your mattress over might be a simple solution to ridding yourself of a smelly mattress.
If you spot surface stains, a quick clean might also reduce smells. Mix soap and water until you have a nice top layer of bubbles. Then capture the bubbles on your hand and dab on to stained and smelly areas. Using a towel, gently rub the soap bubbles into the stain. Use the dry portion of your towel to then press over the area and soak up any water.
For more stubborn stains, first sprinkle on a light layer of baking soda. Baking soda has natural deodorizing properties (its why we use it in the fridge!) Then, combine one part white vinegar (also a natural deodorizer) and one part water in a spray bottle. Mist your baking soda with the vinegar water and allow to bubble up. This should help to loosen dirt particles creating smells. Brush off lingering baking soda, vacuum and allow to dry.
You can then lightly spritz your mattress with a fabric deodorizer or scent, making sure to dab away any wetness. Allow to sit out over night.
Once your mattress is back in its frame, you can also place a few dryer sheets in between it and your mattress pad or cover for extra soft scent.