It's indeed possible for a washing machine to catch on fire because it does contain electricity so if something shorts out in the washing machine then it can potentially start a fire.
However it's very unlikely that a washing machine in good working condition would catch fire but still I would never leave a washing machine on overnight while asleep or when away from home just to be safe.
That's especially true for an electric dryer or gas dryer which could catch fire if lint got built up in it and then destroy your home while you're gone or kill you in the fire if you're asleep.
I've never had a washing machine catch fire but I did have an electric dryer catch fire when I was home and luckily I was able to put the fire out with a fire extinguisher so after that I would never leave either a washing machine or dryer on while away from home or when asleep.