With all the great comments it seems like there's maybe 10 common ways DMs keep recurring villains alive...
Indirect Confrontation: The easiest way to keep a villain alive is to keep them off camera. While the PCs may know about and hate the ultimate villain, they don’t have an actual confrontation with him until the end, instead dealing with proxies as they foil the villain’s plots. Is he a non-combatant with political power that makes him untouchable? Is she a dark overlord of vast power? Or is the villain found/imprisoned somewhere, like another plane?
Ambiguous Villain: It’s unclear just how villainous the villain is. This works best for tragic or sympathetic villains with a sense of honor. Only at the end of the campaign do they show their true face, at which point the PCs may try to redeem, kill, or even rescue them. At various points throughout the campaign, the villain may ally with the PCs to accomplish a mutual goal (though they’d best sleep with one eye open), and a canny villain may play on this dynamic.
Unknown Villain: The villain’s identity is a mystery to be unraveled over the course of the campaign. There should be two or three strong suspects at the end for the PCs to deduce which is the true villain. Several plot twists work here. Maybe it’s a conspiracy and all of the suspects are in on it? Maybe the villain has a change of heart by the time the PCs catch up with him, and now seeks to undo his “mistake”? Maybe the villain doesn’t even realize they’re the villain? For example, a man cursed as a werewolf, a woman possessed by a spirit, or a villain who suffers amnesia or multiple personalities.
Foolproof Escape: The villain devised the perfect means of escape and there’s nothing the PCs can do to prevent it. To avoid feeling forced, this should be hinted at during the campaign, or even outright revealed prior to the confrontation. For example, the villain’s spirit leaps into a new body when they die, the villain possesses an artifact granting mastery over magic portals, or the villain anticipates excessive reinforcement showing up.
There Was No Body: Nobody could possibly have survived that! In the heat of battle the villain “dies” in an explosion, falls off a cliff, drowns in a stormy sea, is buried in an avalanche or cave-in, is swallowed by a portal mishap, etc. However, no one finds a body, and the villain lives to vex the PCs another day.
Special Condition: Villain can’t be killed for good except under specific circumstances, like slain by a blessed weapon, or destroying a phylactery.
Transformation: In the words of Obi Wan Kenobi: “Kill me now and I will become more powerful than you can possibly imagine.” The villain returns as an undead vampire or lich, is recruited into Asmodeus’ infernal army, undergoes divine apotheosis, or otherwise sheds their mortality.
Decoy: To quote Spaceballs: “You fools! These are their stunt doubles!” It wasn’t actually the villain the PCs killed, but a twin, clone, doppelganger, etc. To prevent this from feeling heavy-handed, you’ll want to drop clues during the campaign that suggest the villain has a decoy (or at least is thinking along those lines). This could be as simple as a prince who places a look-alike in his wagon, concerned that he could be the target of an assassination plot.
Dire Repercussions: Killing the villain is worse than keeping them alive, and can lead to tragic consequences. PCs trying to kill a noble or government official would be accused of treason without hard evidence. A zealous villain could become a martyr for his cause, making his followers more numerous and powerful, unless the PCs first weaken his cause. Or perhaps the villain is the only person keeping control of something dangerous, so the PCs must find a way to contain/eliminate the threat on their own first
A Fate Worse Than Death: Perhaps it is the villain’s own doing, or perhaps the vengeful PCs are responsible, but the villain suffers a fate worse than death. Usually this is a player-initiated situation, but a DM could suggest it as a possibility through NPCs. Perhaps they’re trapped inside a nightmarish demi-plane for eternity? Or maybe they’re “rehabilitated” against their will to become good? Or perhaps they’re simply left disgraced and destitute? Or do they spend their remaining days in an insane asylum muttering the heroes’ names?