They need water because they have gills, not lungs. Mammals lungs are designed to enable them to extract oxygen from the air, whereas fishes gills only enable them to extract oxygen from water. There are a few exceptions of fish that have both gills and lungs, but mainly that's why they need water.
Their bodies function to extract oxygen from water (through gills) rather than from air (through lungs).