When installing a LED as an indicator or warning lamp, extra care must be taken.
LED lamps, unlike traditional filament (or incandescent) lamps must be connected with the right polarity (positive and negative must be connected the right way around).
A LED has "ANODE" and "CATHODE" connections. Most LEDs have the CATHODE identified by one or more of the ways shown in the diagram.
A LED must not be connected directly to 12V (or 24V), it must have a resistor in series. Usually 1KΩ (1,000 ohms) or 560Ω is suitable for a normal LED indicator on 12V, but a proportionally higher value of resistance must be used for higher voltages.
The resistor may be connected to the anode or the cathode, as shown below