How can you present the BBEG to the party and ensure his escape without 'railroading' the players into that end-scenario (that the BBEG gets away)? OR, how do I use a BBEG as a tool, and not a killable punching bag?
You can't, but you can protect that outcome to a large extent.
The key to a good villain is to let them develop a relationship with the PC's.
I always try to present the BBEG to the party in a situation where they aren't expecting to find the BBEG. This is I admit difficult after a while, because it's a trope with me - "If there is a dinner party, someone present is probably the BBEG." It's useful to start thinking about presenting the dungeon as if it was not a dungeon. Start thinking about placing BBEG's in story roles that you'd leave to mentors, allies and quest givers. For example, you might place the BBEG into the story initially as the sage that gives the party helpful advice, or as the friendly noble who provides real assistance to the party. They might be referred to the BBEG by a mutual friend. You might think of stories where the BBEG and the party have mutual interests, and have the initial relationship be one of working to overcome something. After all, bad guys have foes who are also bad guys. It will be really easy to slot the BBEG into the 'good guys' bucket if he's helping you fight the cult of the God of Avarice. The fact that he's doing so because he wants the evil artifact of Lug the Terrible for himself is a later complication that you can conceal rather easily.
What you'd like to do is develop the relationship for as long as possible before making the stunning reveal or heel turn. Make sure you present your BBEG as attractive and against type. If they are expecting villains to look like Snape, make the villain look like Dudley Do-Right. If they are expecting the villain to look like Lucius Malfoy, make him look like Harry Potter. It's real easy (at first) to play with your player's biases (until you teach them too well).
An alternative approach is to have your ultimate BBEG always presented in the form of the anti-villain. The PC's establish fairly early on that he isn't nice, but he always seems the nicer alternative to the 'real' bad guy that both they and the anti-villain are working against. The anti-villain might even concede that once they've dispatched the 'real threat', that they'll no longer be allies, and you're trying to build up a 'curse your unexpected but inevitable betrayal scene'. You're BBEG will always need a way to pivot into the role of BBEG if the PC's decide to target him. This approach would be very difficult to pull off in a published module, but you could do it with appropriate advice and trust in your target audience.
Blood relationships to the PC's are cheese, but work well when done right. It wouldn't be hard even in a published module to include this complexity, provided you do appropriate character development as described above.
Once the reveal happens, you have to change from affable friend to Moriarty in a hurry, because the players are generally absolutely ruthless. That means that the villain needs to have well thought out 'encounter plans', and well prepared bolt holes. You'll have to use a bit of cheese here, and the higher the PC level, the more cheese you'll need. For every encounter with the BBEG, you have to have the following:
a) A Barrier: This is the means the BBEG is planning to use to keep from being beat down by the PC's. Generally speaking, you'll want a fairly large space so that it requires more than one round to traverse it. The barrier surrounds the BBEG and protects him. At low level the barrier can be a moat and some mooks (a few orcs, perhaps), or an elevated balcony or window from which the BBEG can address the PCs safely will directing his minions. At higher levels you'll need tougher mooks (stone giants), covered pit traps, walls of force, ect. As levels increase, inner lairs have to be proofed against scrying and teleportation.
c) A Distraction: Usually the barrier is not enough to stop cunning PC's. They'll develop some sort of delivery mechanism for getting a PC across the barrier to threat the BBEG, thereby delaying his escape long enough for the rest of the party to arrive. So as the party gets more sophisticated, you'll need trickery as well. This can include hostages, illusions, minions disguised as the BBEG, and big problems that need solving (the volcano is exploding now, the room is flooding, etc.) In general you could ad hoc this, but if you do you've got a DM PC. Never protect your BBEG with ad hoc devices, because if you do, you've created an invincible character. This is one of the ways improvisational DMing consistently goes so very wrong.
c) An escape route: The escape route needs to not only be accessible, but needs to be something the PC's can't easily follow. Doors are your bane here. I don't know how many villains I've had die because they needed to open a door. The escape route SHOULD NOT BE BEHIND A CLOSED DOOR. That's rule #1. Ideally, the escape route shouldn't be a spell (but see the next entry). Good escape routes involve modes of movement the PC's don't have. A pool of water connected to an underwater tunnel is an excellent escape route if your BBEG is amphibious and the PC's generally are not. BBEG's that can tunnel in loose soil have an even more powerful means of escape. Flight is good versus low level characters but generally unreliable after that. Better is locking covered pit trap that delivers a soft landing. Which leads to rule #2: THE DOOR AUTOMATICALLY CLOSES BEHIND THE BBEG. The escape route has multiple porticullises that drop behind the fleeing BBEG triggered by blocks he steps on or buttons he can mash as free actions. The trap door that drops the BBEG down a chute has a mechanism such that every other triggering sends the person down a different chute. The escape route is in the form of a simple maze. The floor of the escape route is covered with water (to stop or make very difficult tracking by scent or other means). The escape route contains a permanent darkness spell, at a four way intersection, so that the route of the BBEG can't be known. The exit of the escape route has a monstrous guard that delays the pursuing party, but not his master. The escape route has layers, leading to multiple incidents and lengthy pursuits. The party that manages to track the BBEG through the exit passage (perhaps using a disintegrate spell to remove the barriers quickly, and divination to navigate the passages without error), finds the BBEG has gained a round or two of motion on the PC's leading to another room with another barrier, and another escape route - perhaps jumping on the last boat at a dock to an underground river while the formian giant lumbers toward the party. Multiple taunting incidents are good. In fact, you might plan the meat of the dungeon as this sort of chase scene.
d) A backup plan: No matter how good the BBEGs preparations are, occasionally the PC's will outwit you. That's why all good BBEG's have a backup plan that allows for at least one 'get out of death free' card. At the very least, this should be a teleport spell/item. Teleport shouldn't be your first recourse (unless it's quickened, silent, and still, in which case that's pretty durable), but sometimes its essential when you get cut off from your planned escape route (for example, if the PC's find the escape route and enter the dungeon through it). Necromancers are cheese here, which is part of why they show up in so much fiction. How many times does Harry Potter kill Lord Voldemort anyway? Three times just by the end of the second book! My current BBEG is a necromancer who he's got the backup planned covered in spades. In fact, the party has already killed the BBEG twice - once a quiescent clone in a glass coffin and once a simulacrum. In theory, they could kill him at any point and it would only inconvenience him. I plan for him to get killed a lot. Contingency spells are another good option here. Etherealness or gaseous form can work on occasion. Basically you need to have some solution to getting trapped.
e) Strong Defenses against the Basics: The BBEG needs to have the same plans for surviving the PC's going nova on him that the PC's use to survive getting ambushed by monsters. By the time your PC's are blanketed by Death Wards and Freedom of Action, your BBEG better be as well. Stoneskin is great early on, as is Protection from Normal Missiles. If you lack mastery of this, take note of everything that the PC's use to make encounters trivial and use their tactics against them. The BBEG is at least as smart as your PCs.
The chance of any of these plans working is not 100%. As such, as the GM you have to maximize the development of the relationship while minimizing the exposure of the BBEG. Every time your BBEG is on stage, there is a finite chance that he dies. This requires two responses.
First, make sure that you maximize paths of communication between the BBEG and the PC's that aren't face to face. Magic Mouth and Programmed Illusions are good. If the PC's drive the BBEG from his lair, have him appear in the magic mirror on the wall while they are looting his stuff and comment on their success and their treatment of his things. Leave taunts in writing all over the place. Consider the mastery by which Gygax establishes the character of Acererak the Eternal in 'Tomb of Horrors', starting with the hill that has a face. Right from the start he has the players identifying - maybe even unconsciously - the tomb as an active opposing sentient force. Rarely has a published module so effectively established the relationship between the adventurers and the BBEG. In a more urban campaign, have the BBEG send the PC's letters, and leave samples of his writing and letters all over the place - my BBEG's and their minions tend to be extremely efficient in all ways but one, they never get around to burning their mail. Establishing report with the PC's is too important, and it adds to your three clue options. Don't belittle these techniques. Yes, they can be boring if overdone, but as Tomb of Horrors shows, they can even completely substitute for encountering the villain face to face if you do them well. Done in combination with an active villain, I think they work very well indeed. After all, Strahd Van Zarovich is just the sort of villain that sends letters to the PC's via minions.
You don't need to completely avoid physical confrontation, just supplement it. But keep in mind that physical confrontation that depends on cheesy exits or a villain that clearly could kill the PC's but isn't actually trying very hard will eventually even be more discouraging.
And remember, the swagger of minions and mini-bosses accrues to the boss. Merely being the guy who is the mind behind a series of mini-bosses that are themselves great villains helps increase the cache of the BBEG and the relationship with him. Make sure you have the mooks and henchmen refer to their boss a lot and in awed terms.