Haha, it seems you have very little real world experience of raising children. Nobody "teaches" a kid not to swear. That's why almost every single adult swears at least occasionally.
Kids swear because it makes them feel cool, or because they like the reaction they get, or because, as you say, the grown-ups tell them they're not supposed to. But swearing is completely different to a racial slur.
Swearing is an expression of frustration or joy or surprise or any number of things. A slur is an attack on a person. Everybody realises that slurs are rude. That's exactly why some people use them.