V.W.
If it is a HE machine, then always leave the door open after using it... Mine stays open unless there is a load in it (or my husband walks past and shuts it, lol). HE machines are water tight.. which also means they are AIR tight. So if you don't let them dry out in between uses, mildew WILL grow.
Run a "cleaning" cycle (per manuals instructions). Just running a load of whites with bleach may not be sufficient. My particular machine the "cleaning" cycle fills the machine fuller with water/bleach, which is more effective than the lower water level of a "normal" cycle.
My machine recommends doing a cleaning cycle every month or as needed. I do it about once a year, since leaving the door open seems to eliminate the majority of the issue.