The reason is because we’re all washing too often at low temperatures or always using the quick cycle.
Bacteria, which produce gases that give off a bad smell, will survive a 30 degree wash, so when the water drains away, the bacteria are left behind to build up and grow in number inside the machine, hence the nasty niffs (and eventually black mould on the seal).
Do a ‘maintenance wash’: throw a cup of clear vinegar into the empty drum and run the machine on the hottest wash.
Thereafter, make sure you do a 60 degree wash once a week, particularly for towels and cotton sheets. Sweet smells guaranteed from now on.