A musty washer usually contains trapped moisture, detergent residue and lint. Cleaning the actual problem areas works better than adding fragrance.
Door gasket
Water, lint and debris collect in the rubber folds. Wipe accessible areas after washing and leave the door slightly open when it is safe to do so.
Detergent drawer
Detergent and softener can build up into a sticky film. Remove and rinse the drawer regularly if the manufacturer allows it.
Filter and drain
Threads, coins and debris collect in the filter, and trapped water can smell. Follow the manual carefully because water may spill when the filter is opened.
Maintenance cycle
Many washers include a drum-clean program or specify a periodic hot maintenance cycle. Follow the manual and never mix cleaning chemicals.
Bottom line
Keep the solution simple: start with the most likely cause, change one factor at a time, and observe the result. That makes it much easier to identify what actually works in your situation.