Since doing so, I have noticed mold on the walls inside the closet and the smell of mildew. A. Mildew is a common mold that requires moisture.
Moisture can come from water leaks, flooding, high relative humidity, and condensation.
Moreover, the growth of mildew is perpetuated by poor ventilation. Although your question doesn t specify, we guess that you have a gas water heater. Condensation is a byproduct of the gas combustion that occurs at the burner beneath the tank of your water heater. Such is not the case with an electric water heater. Thus, we believe that this, combined with inadequate ventilation in your closet may be the culprit.