As the lungs branch into smaller and smaller airways, the end in specialized sacs called alveolae. Here, oxygen passes through the lung membranes into the bloodstream, and waste products like carbon dioxide flow out of the blood and into the air, and are subsequently expelled when you breathe out.
Fish also need oxygen to live, but their lungs are not designed to extract oxygen from the air.
Instead, by passing the water through their specialized organs (called gills), they can remove the oxygen and eliminate waste gases.
Since humans do not have gills, we cannot extract oxygen from water. Some marine mammals, like whales and dolphins, do live in water, but they don't breathe it. They have developed a mechanism to hold their breath for long periods of time underwater. Eventually, however, they have to come to the surface to exhale and then take a new breath.
The oxygen that fish breathe is not the oxygen in H2O. Instead, the fish are breathing O2 (oxygen gas) that is dissolved in the water. Many different gases dissolve in liquids, and we see an example all the time in carbonated beverages. In these beverages, there is so much carbon dioxide gas dissolved in water that it rushes out in the form of bubbles.
Fish "breathe" the dissolved oxygen out of the water using their gills. It turns out that extracting the oxygen is not very easy -- air has something like 20 times more oxygen in it than the same volume of water. Plus water is a lot heavier and thicker than air, so it takes a lot more work to move it around. The main reason why gills work for fish is the fact that fish are cold-blooded, which reduces their oxygen demands. Warm-blooded animals like whales breath air like people do because it would be hard to extract enough oxygen using gills.
Humans cannot breathe underwater because our lungs do not have enough surface area to absorb enough oxygen from water, and the lining in our lungs is adapted to handle air rather than water. However, there have been experiments with humans breathing other liquids, like fluorocarbons. Fluorocarbons can dissolve enough oxygen and our lungs can draw the oxygen out