Simple answer is they are careful about what they say and have good lawyers that review it.
A few examples.
Calling Tom Cruise a fudge packer in the context of him being in a bathhouse could eaisly open them up to liability for calling him gay. But doing it in a fudge factory while showing him putting fudge in a box gives them a clear defense that they meant it literally.
Simmaraly telling him to come out of the closet while he is actually in a closet provides cover.
Making things so absurd that a reasonable person wouldn't believe it and know it's a joke also works. So having Barbara Streisand aquire an artifact that makes her into a giant robot monster works but something plausible wouldn't.
Having Kanye open up and admit he is a gay fish is absurd enough to provide protection. However they probably couldn't get away with him simply coming out as gay.
Of course the genius of south park is they use these legal protections in ways that make the story funnier and not just for cover.