Musty odor in carpet has a physical cause in mold or mildew. It may grow on the carpet itself, the padding, sub-floor or adjoining wall. Mold and mildew require the right conditions to grow: moisture, warmth and a food source. For this reason, it is not found in dry areas and is not common on carpet made with synthetic fibers, since they are not a good food source. Natural fibers, however, can be quickly consumed by mold and mildew.
Broken pipes and leaky roofs are common causes of wet carpeting, which in turn leads to mold and mildew, followed by a musty odor. A cracked or damaged foundation can also allow water to seep into your home and into the carpet. This situation is not usually as obvious as puddles of water from pipes and roof leaks. Any source of water can also be a source of a leak. For example, a shower leak may run into a closet located behind it and go unnoticed for some time, until mold starts growing and a musty odor become obvious.
High humidity, or constant moisture in the air, can lead to mold and mildew in your carpet, even if there isn't a water leak. Areas such as bathrooms, kitchens and laundry rooms are all subject to high humidity. The water vapor provides enough moisture for mold growth without the carpet being saturated or even feeling damp.
Carpet, with or without padding, installed directly over unsealed concrete can become filled with mildew and mold thanks to moisture released from the concrete. This moisture becomes trapped underneath the carpet, encouraging mold, which in turn creates a musty smell. Concrete should be sealed or a moisture barrier placed between the carpet and the concrete.
Mold and mildew release spores that can cause irritation and illness when breathed into the respiratory tract. So it must be removed as soon as possible. Pull up the carpet and check the padding, which is likely to be covered with mold or mildew as well. Remove and replace affected areas of padding. Carpet may be cleaned with vinegar, borax or other products that eliminate mildew, but in some cases the stains may remain and the carpet will need to be replaced.