Everything we know about stars comes from studying their radiation/light. By measuring the wavelength or frequency of light coming from objects in the universe, we can learn something about their nature. Starts emit a range of wavelengths. The frequency of light is directly related to its color, so it follows that stars have different colors because they have different peak wavelengths of light.