If it is a moldy smell, you will need to clean your washer. Some molds can live in a washer even if you use the soap you have always used. You will need to do a load of whites with some good ol bleach.
Then send it through the dryer, but give it a good wipe down inside with a towel you will put in that washer load first.
My washer is a new one which can actually boil clothes for a sanitary cycle. If you have kids with any yucky stuff in their pants from accidents,and you just put them in the washer thinking it will clean it, this is also an issue.
Sometimes just the air in the basement(if that is where the dryer is)can also be the issue. This is because that is where the makup air is coming from to send all that "dryer vent" air outside. That means cleaning the basement and remove any musty smells.
Made in the