Mold in coffee can be due to spores of mold that may have been present on the green coffee beans before they were roasted or mold that has grown on the surface of the coffee since it was roasted. If mold is present, it will typically show up as a white powdery substance with a musty odor on your ground coffee.
Mold is a type of fungus that can grow on different substances like food, plants and other items. It often appears as small clusters of blue, green, white or black spots on the surface of moldy products including coffee. Although mold eventually penetrates the interior of coffee beans, mold does not usually affect the taste and smell of brewed coffee because it remains on the surface. However, if mold growth has continued unchecked for some time - particularly if the product is highly contaminated with mold spores - it may cause mold to seep into the depths of your drink and potentially spoil its taste and smell – and cause serious health issues.
Mold in coffee can be prevented by storing your beans or grinds in an airtight container that's not transparent so mold won't have easy access to light.