Nail fungus is caused by fungal infections (dermatophytes), not by poor hygiene. While good hygiene can help prevent fungal infections, anyone can get nail fungus regardless of how clean they are. The infection spreads through contact with fungal spores in warm, moist environments.