If you fly too low, or enter a combat zone during combat, you will get a warning, and after a few seconds you will be forcefully dismounted with a parachute-like buff to prevent dying from falling. The parachute lasts until you hit the ground.
You can't fly underwater, but you may be able to mount a flying mount while floating at the surface.
Can't fly too low
In Dalaran during Wrath of the Lich King, you could fly through the city, so long as you remain at least 20 yards above the ground. You could not mount on any flying mount or shift into [Flight Form] or [Swift Flight Form] while on the ground (except in Krasus' Landing).[1] This restriction was removed in Cataclysm.
Can't fly during certain times
In Wintergrasp you can fly through the whole zone, land, and takeoff from the ground so long as a battle is not taking place. During combat you will be forcefully dismounted after a few seconds (though you will also get a prompt asking if you would like to join in the battle, as well, making the debuff a moot point unless a player chooses no in the prompt).
Flying mounts work in Northrend also, but only if the character had [Cold Weather Flying]. So, for those without the Cold Weather Flying ability, Northrend is a no-fly zone.
In Cataclysm
This section concerns content exclusive to Cataclysm.
Kalimdor or Eastern Kingdoms (before you get a Flight Master's License), and Northrend (before you get Cold Weather Flying) act similarly to no-fly zones in that you cannot mount on any flying mount or shift into Flight Form, but you will not be forcibly dismounted, since there is no way to enter these areas while flying.