One way is the type of tree. Because of the certain type of tree the characteristic of the specific specie, it is a way to identify what tree and what type it is. This is just one reason why.
Another reason is the chemical that is in the tree it's self. A couple of chemicals are chlorophyll, carotene xanthophyl and many more. Here are some of the chemicals and the colors they create,
chlorophyll (green), carotenoid (yellow, orange, and brown), anthocyanin (red).