Carbon dioxide is produced by the respiration (not photosynthesis) of both plants and animals. When you exhale, you produce Carbon Dioxide. Pretty much the same with fish except they don’t have bad breath like you do. Just kidding.
One interesting thing about water is that Carbon Dioxide levels can exist independently from the Oxygen concentration. For example, you can have water with plenty of Oxygen, but which also has a lot of Carbon Dioxide.
Carbon dioxide likes to do one thing in water. It likes to convert to carbonic acid. When it does this, it tends to affect pH by bringing it down into the acid range. So, a bunch of fish breathing in a small tank with minimal circulation and surface agitation may actually accumulate sufficient carbon dioxide to drag down the pH due to the carbonic acid equilibrium that will result.
Removal of carbon dioxide (with its carbonic acid behavior) by increasing surface exposure and gas exchange will remove the carbonic acid and may raise the pH above neutral.
Do you remember in the discussion of Ammonia when I mentioned that Ammonia is more toxic at a higher pH? Well, this created a problem for some fish once. Someone had the idea that if you deprive the fish of aeration, you will preserve a high carbon dioxide level. The carbon dioxide level will keep a higher carbonic acid level, which will keep the pH down. The lower pH will ionize the Ammonia to Ammonium and preserve the fish from Ammonia damage at shows.
So, at least for a while, it was a widely perpetrated myth to enjoy gasping fish at shows, and use autogenous Carbonic acid to lower the pH, rather than do a water change to remove the threat from Ammonia.
Carbon dioxide has a partial pressure in the air, when oxygen goes up, carbon dioxide has to go down. In water; NOT SO. You can have crazy CO2 levels with high O2 levels and vice versa or any mix.
The most amazing myth: “Don’t oxygenate Show Tanks” because it blows off carbon dioxide [carbonic acid], raising the pH and causing the ammonia to become more toxic.