The obvious answer is that, like us, they see light. Just as we have photoreceptors in our eyes, they have their own throughout their stems and leaves. These allow them to differentiate between red and blue, and even see wavelengths that we cannot, in the far red and ultraviolet parts of the spectrum.