
Because color is determined by skin tone and blood flow. Lighter skin has an uneven distribution of capillaries (tiny blood vessels) that fill or deflate based on arousal, size, hot/cold etc. Darker skin tones have the same thing but also melanin and now new/old the skin cells producing it. This is also influenced by blood flow.
Because the end goal of all life on earth is reproducing (from a biological perspective), the penis has to have an incredibly complex network of blood flow not only to maintain an erection, but to thermoregulate because sperm will die or not be effective if out of its preferred temperature range. So the blood flow is mainly on the surface, to keep the penis at a relatively lower temperature than the inner body.