Most whales live in the ocean, so many people would think they are fish. But in fact they are not fish, but mammals in the water. Therefore, the way fish breathe with gills is not suitable for whales. As an aquatic mammal, they breathe in the same way as terrestrial mammals, using lungs to breathe, so they must have lungs. There is a big difference between breathing with the lungs and breathing with the gills. When fish use gills to breathe, they can breathe directly in the water, but whales can't breathe in the water when they use lungs. Whales don't have enough oxygen around them, and they need to come out of the water to breathe.
As mentioned above, whales breathe with their lungs. Moreover, because the oxygen content in the water can not meet their requirements, they need to breathe at the surface. Whales are very active and consume a lot of energy, but they can remain breathless for a long time after a breath, which is very different from the breathing of humans and most other animals. Large enough lungs are the main reason for this phenomenon, because only the lungs are large enough to ensure that they can submerge for a long time after a breath.
Specifically, whales vary in the size of their lungs. The bigger the whale, the bigger its lungs. For example, if a giant whale weighs more than 100 tons, its lungs may be hundreds of kilograms or even up to 1000 kilograms. Of course, this giant whale is relatively rare. Other smaller whales have smaller lungs, but they must be much larger than other animals' lungs.