Is this why people Wash out their mouths with soap after swearing? Because they felt their mouth got dirty?

Native speaker’s answer
Rebecca
It's an idiomatic expression, people don't actually wash their mouths out with soap! But yes, swear words are considered to be dirty and crude, so that is where the expression came from. Ex: Go wash your mouth out with soap. No swearing is allowed! Ex: Don't say that, that's a dirty word.