Unlike fish, which are non mammalian animals, dolphins do not possess gills (gills allow fish to extract oxygen from the water) so they must come to the surface of the water to breathe.
While dolphins breathe air like other mammals they also breathe in a way that is unique to most mammal species.
In order for dolphins to inhale and exhale they must breathe through their blowhole, not their mouth.
The reason for this is that there is a major difference between dolphins and land mammals which is the fact that dolphins live exclusively in the ocean, so in order to maximize their survival and make life easier they have developed separate holes for breathing and eating.
So while humans (and most land mammals) can both breathe and eat through their mouth dolphins can only breathe through their blowhole and are incapable of breathing through their mouth; in fact dolphins don’t even possess vocal cords.
This is very important for a number of reasons.
First, when a dolphin dives underwater it is actually holding its breath.
In order to prevent the dolphin from accidentally sucking up water when hunting for and consuming prey the dolphins esophagus (food passage) remains separate from its nostrils and lungs (air passage) which is connected to its blowhole.
If a dolphins air passage was connected to its mouth and it accidentally inhaled water while hunting for food underwater there is a good chance the dolphin would get water in its lungs and possibly drown, so in theory it is extremely important that the dolphins air passage isn’t connected to the dolphins mouth.
Second by having a blowhole on the top of its head a dolphin can rest at the surface of the water without having to lift its head all the way up to breathe.
This can be extremely important when dolphins are at rest near the surface of the water as it makes it much easier for these marine mammals to acquire the oxygen they need with as little effort as possible.
Dolphins are known as conscious breathers, meaning they never fall completely asleep because if they did they might drown, so when they go into a resting state half of their brain remains alert in order to allow them to easily obtain oxygen when necessary.
Note: Remaining semi-awake can also help the dolphin react quickly to potential threats or predators by maintaining some awareness of its surroundings.
When a dolphin is seen spouting water from its blowhole it is actually water that has collected around the blowhole when the dolphin was submerged; it is not water that has entered the dolphins blowhole and/or lungs which could cause the dolphin to drown or panic.
In order for a dolphin to dive into the water without worrying about inhaling water when it is submerged the muscles surrounding the dolphins blowhole contract to prevent the dolphin from accidentally taking in any unwanted water.
As far as how long a dolphin can hold its breath varies depending on the species.
Some dolphins can only hold their breath for a few minutes (3 - 7 minutes) while underwater, while other species have been known to hold their breath for over 20 minutes during deep dives.
Most of what is known about a dolphins ability to hold its breath is from observations of their dives.
It is possible the their ability to hold their breath is a result of their physiology.
Some species of dolphin may simply possess better lungs, organ systems and breathing control than other species or it could be the fact that some dolphins hunt for food at deeper depths, so they generally take longer dives than other species.