If your carpet develops a wet or musty smell because of a flood from clean water, it is possible to remove the odour depending on the level of saturation. Once you stop the source of the flooding, lift one edge of the carpet to make sure that the subfloor and padding are dry. If the padding has been saturated, it will have to be discarded and replaced. You can then proceed to remove the wet smell in the carpet with a few household items.
Remove all furniture from the room, if possible. Fill a steam cleaner with vinegar instead of carpet cleaning solution. Full-strength white vinegar is antibacterial and will kill mould and mildew. Steam the carpet with the vinegar solution and allow it to dry. Place fans in the room or open the windows to accelerate drying.
Sprinkle baking soda over the entire surface of the dry carpet and allow it to sit for several hours or overnight. The vinegar smell should dissipate as the carpet dries but if it does not, the baking soda will help to remove the smell as well as freshening the carpet.
Vacuum the carpet thoroughly to remove all of the baking soda.
If the smell is caused by extensive mould under the carpet, wear gloves and an N95 respirator mask before handling it and perform mould remediation procedures. Consult a professional mould removal specialist if necessary.