There are is thing called anthocyanins this is what turns the leaves red. The anthocyanins protect leaves from sun damage so when winter comes the tree and leaves won't freeze . This also helps them to stay on the tree longer. This lets the tree to have more time to gain more nutrients from its leaves. (Yellow and Orange) There is a thing that is called a pigment it holds all the yellow and orange colors. The way the leaves are green is the chlorophyll. It turns off when the air gets cooler. The tree knows that the seasons are changing so it will freeze if the leaves are still green. When the leaves turn brown that means all of the waste in the tree that the tree doesn't need.