Some do it as a defence mechanism, some do it for breeding, but regardless of the reasons most fish are very capable of jumping and quite a few are exceptionally good at it. Some species, such as Pangio spp. and Erpetoichthys calabaricus, are even known as escape artists, requiring extremely tight fitting covers for their aquaria. Jumping fish can easily become a problem as the fish can hurt themselves or even manage to escape and die.
In home aquaria, fish most often jump when they are spooked, so the primary point of concern is making sure that the aquarium is located somewhere that the fish are not disturbed. A suitable location would be in a dining room or a relatively quiet lounge, away from the doors, preferably where no one would walk by the aquarium on a regular basis. While most fish jump for the sake of jumping, I have also heard reports of an increase in jumping in waters that contain ammonia and I have had a pleco that took to jumping with age.
Of course, it is also important to discourage the fish from jumping. This can be done by adding floating plants, as fish are usually less inclined to jump through a barrier. Even with floating plants, a cover glass is highly recommended as the plants are no guarantee against jumping.
With all of these precautions, the dangers still remain as a fish can hurt itself if it jumps into a cover glass, so it is best to use all of the above measures in combination.
Most fish can not survive out of the water for long, some species, such as gouramis and certain catfish can because they are able to breath even when out of the water, so it is always worth checking if the fish is still alive if it is found after it has jumped. Chances of survival, as long as it is still alive, are quite high. It is usually recommended that the fish is floated in a shallow contained with increased aeration until it is able to swim and then, transferred back to its aquarium.
I thought it would be wise to mention all of these things as I am now down to 9 Danios because one male jumped around 40 mm up, through the opening for food (approximately 50 by 100 mm) and onto the floor, then made its way approximately 1 metre away from the aquarium, where I found it dry and dead by morning.