It could be mold and mildew. Two things to try. The first is to replace the hose cables from the faucet to the machine. These should be replaced every couple of years anyway, and if there is mold in there, the first water out of it could be pretty smelly. After that, try running a cold water cycle with bleach and a cup of vinegar. That should kill off the mold and mildew. or
Washing machine odor is caused by a buildup of detergents and fabric softeners. This slimy, odor-causing buildup is hidden inside your washer which is the perfect environment for fungus to grow in. The fungus smell from the washer makes your towels smell like mildew and can even affect people with allergies and asthma! Google "smelly washer"