I had this problem with my last washing machine, I read up about what causes it before I got the new one earlier this year. It’s a combination of using liquid rather than powder, using conditioner, washing at low temperatures which doesn’t kill bacteria, and using the drawer which flushes the liquid or powder into the machine with cold water, and not using a cleaner/descales periodically. I now use just powder, and put it straight into the machine with the clothes. I’ve had no problem with smells at all since.