You can't literally fly in Team Fortress 2, but you can get airborne with Rocket Jumping and Sticky Jumping. By firing explosives (like a rocket launcher or sticky bomb launcher) at your feet, you launch yourself into the air — a technique widely used to reach high ground quickly.
If you're on a server with sv_cheats set to 1, you can also use the noclip command, which disables collision and lets you move freely through the air.