When I first heard that phrase I had visions of jokes on little legs running away and on second thought ot me running way because some of the jokes one hears on TV are so awful that my first instinct was indeed to run away.
Neither of those explanations, however, are correct. A running joke is one that continues throught a work of literature, in many episodes of say at TV sitcom or a comic.

Once again the pirates ship has been reduced to rubble by Asterix and his friends. pic: asterix.co.nz
Running jokes may start out unintentional and may not even very funny in the beginning, but over time and with the repetition and usage – sometimes in inappropriate contexts – the running joke or running gag becomes funny – at least to those who know about the joke and anticipate it. It is less funny or interesting for those who aren’t in the know, that is, don’t know about the joke and don’t expect it.
A lot of spoofs about movies use quotes from the original and make them into running gags.
An example for this from one of my and my son’s favorite comics: Asterix. In many (all?) of the books a band of pirates makes an appearance and they always get beaten badly and their ship wrecked by the Gauls . As soon as a reader sees the pirates he/she knows what’s in store for them. And the pirates know it too, on occasion they destroy their own ship just so the Gauls can’t do it for them. Their inability to fight Asterix and his friends has become a running gag.