oxygen is an atom though, and can't be destroyed, only recycled
co2 is not so permanent, being a molecule
Plants produce CO2 (Carbon dioxide) all the time as a metabolic product of respiration, but when light is available, they can use and fix some of this CO2 as a substrate in photosynthesis. When light is available, they also take up additional CO2 from the surrounding atmosphere, and one of the the end products of photosynthesis is O2 (molecular oxygen), so when light is available, on net balance they use/fix more CO2 into other molecules than they produce, and so produce more O2 than CO2.
When light is not available, i.e. when it is dark, they do not have an energy source for photosynthesis, and so cannot fix CO2 and produce O2, but of course they must continue to respire to stay alive (and hence continue to produce CO2), so they become net producers of CO2.
Depending on the species of plant and the environmental conditions, most plants are net fixers/users of CO2 and producers of O2 when averaged out over the course of a light/dark photoperiod (usually 24 hours).
https://www.quora.com/Do-plants-emit-carbon-dioxide-at-night
and then winter comes along...