Front loading washers smell because of mold formed by water collecting around the rubber door gasket. As of April 2013, nine court cases had been filed against Whirlpool for unpleasant odors emitted by front loading washers.
To prevent mold from forming in a front loading washer, run the machine on a hot water wash with or without chlorine bleach, wipe the door gasket and glass when the cycle has finished and leave the washer door open between loads to allow air to circulate.
A dehumidifier in the laundry room can remove some of the dampness that increases mold growth. If the washer continues to smell or form mold, contact the manufacturer. Top loading washers do not have a rubber door gasket and do not have issues with mold.