Uh-oh! You should have your carpet professionally cleaned. Mold does not grow on the carpet, but rather on the dirt on the carpet. Additionally, locate and repair the source of the moisture to prevent it from coming back. It is best to call a professional water restoration cleaner in order to ensure all mold is eliminated. A quick Google search of "water restoration cleaner near me" should help you find a local professional.
See this article from the International Association of Certified Home Inspectors for details on mold prevention https://www.nachi.org/carpet-mold.htm