When maple trees' leaves are green, they are absorbing sunlight and carbon dioxide. The chlorophyll in the leaves enables them to turn those two ingredients into glucose, a kind of sugar which gives them energy and helps them grow, using a process called photosynthesis. When the photosynthesis stops, the glucose is trapped in the leaf. Sunlight and cold weather turn the glucose red. Oaks turn brown because of the wastes left in their leaves, but the brown leaves don't actually drop from the tree. Instead, they stay on the branches until late winter or early spring, when the new leaves replace the old ones. Other pigments found in leaves called carotenoids are yellow-colored, which is why aspen and larches turn golden. You can't see the colored pigments in summer because the chlorophyll's green coloring is stronger than the others. It is only when the chlorophyll fades out of the leaf that the others are visible.
Later on, in late fall or winter, the deciduous trees lose their leaves because, although their trunk and branches will not freeze, the leaves cannot endure such frigid temperatures. Also, because winter has less sunlight than the other seasons, the leaves cannot make very much energy. It is more efficient for the tree to live off of the energy it stored, just as many hibernating animals live off of the food they ate in the warmer seasons.
Evergreen trees have their own system of coping with winter so that their needles don't freeze. They have a waxy coating on the needles and their cells have fluids that prevent freezing inside them. So while the deciduous trees aren't producing any oxygen, the evergreens take over. This is yet another reason why it's important to conserve these valuable resources.
This is how trees produce the colors commonly termed "fall color" before shedding the leaves, a beautiful annual phenomenon.