There are two common causes of a smelly washing machine
(1) congealed old soap and fabsoft. This is usually caused by excessive amounts, and/or doing lots of low temp washes. To cure it, take out the powder drawer first, and scrub it, and the aperture it slides into, in hot water (you may find it has black mildew in it, in which case you can use kitchen cleaner with bleach and an old toothbrush). Then do a max temp wash, with NO POWDER OR LIQUID and preferably some old white cotton towels. If the water foams up, you will know it is from the resident old soap. Do it again until the water is no longer soapy. Veey rarely, if you use a lot of bath oil or moisturiser, or work in a chip shop, and do cool washes, the inside of the machine gets coated with grease. In this case use Ariel powder and a max hot wash (and those old white cotton towels) to clean the tub. Check that the pump filter is not blocked with rotting socks or fluff (check your instruction book for how)
(2) luckily less common
If the waste hose connects to the sink waste, it is possible for old sink water to drain into the machine, including tealeaves, bacon fat etc. To cure this, either put the crook of the waste hose into a waste standpipe (this needs a bit of DIY plumbing if you do not already have one spare) or else lopop up the waste hose so that it higher than the water level in the sink, and preferably looped up so it is right up against the ubderside of teh worktop or draining board. As water will not flow uphill, this will stop sink water running into the machine. BTW never pour fat down the sink as it sets in the pipes and is horrible to remove.