If algae produce oxygen in a pond, how can having too much algae cause an oxygen depletion?

Like all green plants, algae produce oxygen during the daylight hours as a by-product of
photosynthesis. This is usually a major source of oxygen in fish ponds. In darkness, however, all plants consume oxygen, including algae. Algae blooms in natural water bodies or fish ponds normally produce much more oxygen in the daylight than they consume during the night, but some situations reduce the amount of oxygen a bloom produces without reducing its nighttime oxygen consumption. Trace minerals or nutrients needed by the algae are occasionally used up, causing some or even all, of the bloom to die back temporarily. The resulting bacterial decomposition and loss of normal oxygen production can lead to oxygen depletions and fish kills. Pond water generally changes from a deep green to black, gray, brown or clear after a phytoplankton die-off.
An additional problem caused by dense blooms, especially in excessively deep ponds, is stratification. As mentioned elsewhere, stratification involves layering of the pond water into warm, oxygen-producing upper zones and cool, oxygen-consuming bottom waters. Shading caused by dense blooms limits photosynthesis and dissolved oxygen levels at the pond bottom, resulting in a buildup of potentially toxic compounds, even in aerated ponds. This situation can lead to physiological stress, reduced fish growth, and even fish kills if bottom waters are mixed too rapidly with the rest of the pond. This type of mixing, referred to as a turnover, occurs when cool rain water or heavy wind on the pond surface breaks down layering patterns. Turnovers are often observed in natural waters and ponds in the fall or spring after severe weather disturbances. The potential for a turnover can be detected by an increasing temperature difference between a pond’s bottom layers and its surface waters. If a turnover is likely, prepare for aeration when necessary.
Algae blooms also respond to changes in the weather, and the denser the bloom, the more severe the response can be. Photosynthesis slows down under cloudy conditions, and, as a result, oxygen production decreases. Extremely calm days may also reduce photosynthesis and oxygen production, even under sunny conditions, by preventing phytoplankton in the middle layers of the pond from mixing near the brighter surface. In summer, oxygen problems may arise because of a simple physical property of water. The warmer the water, the less dissolved oxygen it can hold. When a dense bloom produces a surplus of oxygen on a summer afternoon, the oxygen will not stay in solution and escapes into the atmosphere. During the night, the bloom attempts to take more oxygen out of the water than what remains from daytime photosynthesis. When this occurs, dissolved oxygen levels approach zero.