To eliminate the mildew smell, wash the offending towels in the hottest water that is safe for the fabric, using two tablespoons of baking soda in both the wash and rinse cycle. A second, water-only rinse cycle, after the baking soda rinse, removes any remaining residue.
Often a mildew smell develops due to towels remaining wet too long. Taking the time to hang towels up after each use allows them to dry before mold or mildew spores can start to grow. Making sure to move the towels from the washing machine to the dryer as quickly as possible after the wash cycle helps to stop mildew growth as well.
When washing towels, using too much laundry detergent is detrimental to preventing bad smells. The detergent does not rinse from the towels and traps dirt and odors inside the fabric. Fabric softener often traps odors in the fibers as well, and makes towels less effective at drying one's body.
If, despite one's efforts to keep towels smelling fresh, they continue to have a mildew smell, the problem is sometimes in the washing machine. Several front loaders have a reputation for holding water inside the boot (the rubber door seal), but top loaders also develop a mildew odor, especially when the temperatures are warm. Running a load with bleach before washing the towels sometimes helps to eliminate the smell.