Other good points that we’ve discussed in the comments below. [keep in mind these tips also apply to your dishwasher as well including leaving it open to dry out].
1. Run an empty load at least once a month with hot water and bleach or vinegar or with a specialty-made washing/dishwasher cleaning fluid.
2. At the bottom of your washing machine there is usually a trap to catch small objects right before the pump. It should be checked and cleaned out at least every couple of months. You’ll find all those old socks you lost in there and they’re going to be gross as hell.
3. The above goes for your dishwasher as well. There’s a trap underneath the jets at the bottom that is made to be disassembled and cleaned. If you’ve never done it before CAUTION it’s gonna be super nasty.
And 4. Be careful how much fluid you’re putting into your machine, too much can cause the buildup of soap scum/goo.