South Park rather famously DIDN'T know it would happen. They totally fucked things up last season assuming Trump wouldn't win.
As for the Simpsons, you have to realize that they started in 1989, and the 80s were when Trump burst onto the national scene. And he burst on fully formed, too, like he was Athena erupting from the head of Zeus. The Trump we see in the White House right the fuck now is almost identical to the Trump who was getting plastered all over Page Six of the New York Post back in the 80s. So you can imagine that The Simpsons would have looked at him as a target-rich environment, so to speak. They have literally been making fun of Trump for decades. And, as
>>94868747 says, Trump has talked about running for president for ages, so it's only natural that the show has done multiple President Trump jokes.