If it is incandescent, then temperature to some extent, but mostly the light of the wrong color gets filtered out by the colored glass bulb. If it is something like electric discharge lamps, then it is the gas used (eg sodium vapor) or the phosphors coating the inside of the tube converting UV to visible light/color (eg mercury vapor UV emissions). With LED lights it is either near UV being down converted by a phosphor, or the emission is directly tuned to be at a specific wavelength (color). That's one reason why colored LEDs are so efficient - nothing has to be filtered out.