How come my transistor doesn't work?
Is there the only wire from Arduino to the Base of Transistor?

Basically you need something like this:


If you reverse the transistor (E and C), builtin protection diode will be in forward direction, so electro magnet is on.

If you have only one wire to the base, it cannot work as you need current to the base.

If you don't have R1 into the base (about 500R-1K), it'll burn your output eventually. (not if you don't have common ground)

If you have electro magnet between ground and Emitter, you'll have negative current feedback and about 4.2V on L1 tops as there must be some current into the base.