These compounds form during the catabolism of carbohydrates and lipids in condensation reactions, and in some other metabolic reactions of the amino acids.  Oxygen is produced by plants and some bacteria in photosynthesis, while CO is a waste product of all animals and plants.  Nitrogen gases are produced by denitrifying bacteria and as a waste product, and bacteria for decaying yield ammonia, as do most invertebrates and vertebrates.  Water is the only liquid waste from animals and photosynthesizing plants.