We had the same problem after me moved into our house in November last year. I found this solution on Pinterest and it worked.
10 Genius Tips to Clean a Smelly Washing Machine (Fast + Easy)
I couldn’t believe the dirt that came loose and it totally eliminated the smells. Very simple and uses vinegar and baking soda!!! No problem since