Out of the many places where mold can start growing, your carpet might be one of the more problematic spots. Why is that? For one thing, once you actually can see the mold, you are already dealing with a serious problem. In most cases, the mold will grow underneath the surface, either on the underside of your carpet or in the carpet padding.
Many times, mold growth starts when there is water that leaks into the carpet. This could be from something as minor as a spilled glass of water or an open window in a rainstorm, but the problem is much more likely if there has been flooding or a similar major event.
Carpets that have been wet for over a day might need to be replaced completely, just to be on the safe side. If you do find a small patch of mold underneath your carpet, it might be possible to clean it.