Why do I have to put my transistor after of my component, instead of before?
I suppose you used an NPN transistor.

To make an NPN transistor conduct from its collector to its emitter, you must apply a voltage to the base about 0.7V higher than the emitter.

Look at this:







simulate this circuit &ndash; Schematic created using CircuitLab

The base must be 0.7V higher than the voltage applied to the LED.  If the LED were to light up, it would have about 24V across it.  You must therefore apply about 24.7V to the base of the transistor.  But, the Arduino can only put out 5V, so the base never gets enough voltage to let the transistor conduct.

Compare with this:







simulate this circuit

Now the base only has to reach 0.7V as the emitter is at 0V.  That's easy to do with the 5V output from the Arduino.

I left out a series resistor for the LED because if it is intended to operate on 24V it will already have some kind of current limiting built it.



I don't know what happened to your Arduino.  It is easy to destroy an IO pin with too high a voltage.