Certain wild Pokémon can escape from battle. Pokémon that are legendary or found in the region's Safari Zone are the only ones who flee.
Roaming Pokémon attempt to flee every turn, and trapping moves can be used to prevent this, such as Block.
In the Safari Zone, Pokemon can also flee from battle. In order to make it less likely for the Pokemon to escape in the Safari Zone, you must throw it Bait or Pokeblocks depending on which game you are playing.
In Gold, Silver and Crystal a few species of wild Pokemon can flee from battle:
10% Chance of escaping every turn:
• Mr Mime
50% Chance of escaping each turn:
100% Chance to escape each turn
• Suicune (except in Crystal)
If a wild Pokemon uses a move such as Roar, the battle will ens and the Pokemon will flee.
Also most Abras in the wild only have one move, Teleport, and so will Teleport away in battle. (Thanks to Nebula-Night for that :D)