Why Does My Washing Machine Smell Bad?
A washing machine can develop odors when moisture and residue remain inside parts of the machine.
By Everyday Home Advice Editorial Team

A washing machine can develop odors when moisture and residue remain inside parts of the machine.
Leave appropriate areas dry
Follow manufacturer guidance for allowing moisture to escape between uses.
Check accessible areas
Depending on the machine, residue may collect around door seals, detergent dispensers, and other accessible surfaces.
Use the right amount of detergent
More detergent isn't automatically cleaner. Excess product can contribute to residue.
Run manufacturer-recommended cleaning cycles
Use the cleaning process specified for the machine.
What if it smells like sewage?
A sewage-like odor may point to a drain or plumbing issue rather than ordinary washer residue.