There are many reasons that flowers have different colors, and most of these are biological in nature (plant pigments, chlorophyll and ultraviolet light), with the most important being the benefit that insects derive from flowers being "color-coded"--pollination.
Flower color is due to reflected light from the pigment in the plant. These pigments, or compounds known as anthocyanidines, are the basic ingredient in the production of flower color.
When anthocyanidines are combined with plants that have sugar, they create yet another compound (anthocyanine), producing fall-like colors; but there are many more pigments that affect flower color, such as flavanols, flavanoids and chlorophyll, to name just a few.
In addition to plant pigments, ultraviolet light exposure, pollination and even the environment impact flower color.
A flower will look one color, or one shade of that color, when the morning sun hits it, and quite another color or shade if viewed in the evening, or if planted under a shady tree.
Flowers located in colder geographical climates tend to have more vivid colors than their southern counterparts. Flowers in warmer regions sometimes suffer from heat and water-deprivation, resulting in fading color.
When a plant has aged passed the point of pollination, it might actually change color in order to signal to insects that they shouldn't waste their time in seeking pollination.