Shulamit Widawsky is right about the emotive loading of words affecting their memorability.
In the specific context of dirty words, you may well have been highly motivated to learn them. (There’s always keen motivation to learn dirty words in foreign languages, as evidenced here on Quora.) If you were strongly motivated and were delighted by the frisson of taboo, then the words are likelier to have stuck.
Does that mean naughty words should be prioritised in language textbooks? Well, if you’re taught them boringly by rote, all the fun goes out of them, and if all the fun goes out of them, you’re less likely to remember them. So in fact, maybe not.
I’d say getting people to look up their own words, as they need them in composition, can be very helpful, for a similar reason: it’s a word you needed, and invested some effort in. A lot of my German and Klingon stuck that way.