Front-loading washing machines are prone to two different odors. The first smell is musty or earthy and might remind you of a dank basement. That bad smell is caused by mold. The other odor is foul and will remind you of something rancid or rotten; it is caused by bacteria.
Both mold and bacteria grow inside a front-loading washer when it has been overloaded with loads that are too large. The washer does not rinse away all dirt and soil after a big load, leading to a build up of grime inside the washer. This buildup gives mold and bacteria a place to grow and thrive.
You can prevent bad odors in your front-loading washing machine by washing smaller loads inside of it. You can clean the inside of your washer using a mixture of 1/2 cup of bleach in a gallon of water. Running an empty load with hot water and adding a cup of bleach to the water will also remove mold and bacteria.