The short answer is that they reflect light, and they reflect certain wavelengths better than others, giving them a certain colour (although it also depends on the spectrum of the source that is illuminating them).
This is how dyes and pigments work, by selectively absorbing some wavelengths and reflecting others. For example, that's why chlorophyll is green -- it absorbs other wavelengths and reflects only green. But if you illuminated chlorophyll with purely red light, it would appear black, because it would absorb the red light, and there would be no green light from the illuminating source to be reflected back at you.
Another example from everyday life: it's always annoying when the colour of clothing looks different in daylight than how it appeared under the store lighthing when you bought it.