The main thing to remember is that the water-air system is always striving for equilibrium. If we assume that the air is constant (your tank is not going to significantly affect the composition of air in the room/building) air is 78% nitrgoen, 21% oxygen, and CO2 in the air is 0.033%.
If you give water and air system enough time, this will be the percentages you find in the water, too. What is enough time? well, if you just sit out water and dont agitate it or impose movement in it, it could be days. However, with the currents caused by filters, airstones, and even the fish themselves the tank can be considered to we pretty well mixed, which means that gas exchange will depend solely upon the surface.
If the surface remains undisturbed (filter output underneath the water level, no airstone) the rate of gas exchange is slow, but bubbles and filter returns increase the agitation which significantly increases the gas exchange.
However, whatever the rates of gas exchange is, the system is always striving toward equilibrium. What I mean is that, in your tanks, you have a sink of oxygen, namely your fish and the plants at night. That means oxygen from the air will always be trying to get into the water.
Similarly, you have a source of CO2, the fish again, and the plants at night. During the day, there is both a source (fish) and a sink (plants) of CO2. So, depending upon the fish and the plants, there may be CO2 leaving the water or CO2 entering the water at the water-air interface. CO2 is not necessarily driven off at the surface, nor will any other gas, it all depends on where your tank is as compared to equilibrium. Most likely, however, the CO2 levels in the tank are higher than 0.033%
Typically, plants can be a very strong sink of CO2, which is why people construct the CO2 injectors. Now, this suppplements the CO2 from the fish with CO2 from another source. In this way, compared to equilibrium, the CO2 in the water is over equilibrium, so at the air-water interface, CO2 will leave. This is why those with CO2 injectors typically try to minimize surface distrubances, to that the rate that the CO2 leaves is lowered. And, when the lights go off, the plants are now one of the three sources of CO2 (fish, injector, plants) and with the two sinks (fish, plants) and minimal surface disturbance, the O2 levels may get too low to support life.
In a similar manner, this why extra agitation is recommended when medicating -- many of the medicines are oxidizers, they attack the protozoa or bacteria by taking oxygen from the water and attaching it to the molecules in the infective creature. In short, the working medicine acts as a sink of oxygen, which again will pull the system out of equilibrium. The increased agitation will help increase the rate at which the system reaches equilibrium.
There are more complicated issues, like the solubility of CO2 is like 20-30 times the solubility of O2 in water, but ultimatly, if you just consider that the system will always be striving toward equilibrium and the greater the air-water surface disruption, the quicker the system will hed toward equillibrium, you can get a long way in analyzing and understanding your tank.
p.s. if you would like to see a fairly refreshing read on how to successfully keep a planted tank, Diane Walstad's Ecology of the Planted Aquarium is very informative. She does not believe that CO2 injectors and a whole bunch of fancy equipment is needed. Just some basic sense.