Overwatered indoor plants are not the only reason gnats can appear. Fungus gnats can also lay their eggs in moist organic materials like dirt, mulch, and compost. Fungus gnats are attracted to light, rotting leaves, and damp mulch in flowerbeds. These pests can come from anywhere there is dirt, moisture, or light.