So here is what I have read on this issue in the past:
1) Leave the door open at all times as these front loading units seal so tight and the combination of moisture and bacteria that like to eat soap scum is bad.
2) Once every month or two run a cleaning cycle. People use Affresh, Bleach or Vinegar. The Affresh type products are suppose to break down the soap scum that bacteria is eating at and causing the smell
3) The other thing is that some washers have a screen/filter that gets plugged in front of the pump. You’ll see some newer units have a small access panel in the lower corner. If yours doesn’t you might have to unscrew and pull off the panels to get to it. It really depends on your washer and you can probably google cleaning for your specific model and get some results.
-Tim