Smelly washer

When I wash my clothes, they always come out smelling like mildew or like they’ve been sitting in there forever when they haven’t. I switch them to the dryer immediately and I use Gain laundry detergent and lavender scented dryer sheets and they still smell like garbage. I’ve even bought tablets that clean the washer and nothing still happens