Wet carpet can cause the smell. Smell can also come from evaporator due to buildup of fungus. In that case you will need to go for AC service.
To prevent growth of fungus always switch off AC a couple of minutes before you stop the car. Let it run on fan and turn off recirculate button to let some fresh air in. That will get rid of the condensation on the evaporator and prevent growth of fungus.