Carpet sprays are formulated to resist moisture and inhibit soil growth. If a carpet resists soil, there is less organic matter to feed mold and mildew. Moisture- and soil-repellent sprays will only help carpet resist mold if the carpet is in a room with only a little flood encroachment.
If you have a room frequently touched by moisture from flooding that recedes quickly, try applying moisture repellent spray and soil repellent spray in a light coat throughout the room according to manufacturer's instructions, prior to flooding. Do not over-wet the carpet. If the carpet is installed on a pad, it might help to spray the pad as well. Use a sump pump and dehumidifier in affected areas.
If the carpet or pad get soaked during a flood, they may still need to be replaced, ripped up and dried, or cleaned, even if treated by repellent spray.
Because mold is a fungus that reproduces by dispersing microscopic spores through the air, areas that can't dry quickly may need multiple applications of a spray that kills fungus to prevent mold growth. Install a dehumidifier to help dry the room quickly, and use an air cleaner to help remove mold's spores from spreading.
Spray carpets with a fungicide approved for use on interior textiles. If possible, remove the carpet from the home and dry it in direct sunlight. Even if you can inhibit mold growth in the carpet, you may need to discard the pad. Remove the pad to clean the concrete or check the wood subfloor. After cleaning debris and organic matter from the concrete, apply a household bleach solution to inhibit mold growth.
Spray the wood with fungicide and allow it to dry in fresh air if possible, or replace the subfloor. In easily flooded areas with concrete flooring, consider gluing down carpet directly to the concrete instead of installing a subfloor or pad.