Understanding Electric Shock Box Circuit
The transistor and the transformer are a blocking oscillator. 

That is the source of the AC needed to generate high voltage through the transformer.

The signal it generates is a series of pulses.  It isn't a nice, smooth signal like a sine wave.  The transformer doesn't (much) care.  It works with any varying voltage.

The transformer has to have a high ratio of turns (many times more turns on the secondary than on the primary.)



I wouldn't try to duplicate the circuit with just any random parts.   It most likely wouldn't work, but if it did then you can't be certain that it won't deliver a lethal shock.

With the kit, you can sort of expect someone to have made an effort to ensure that it is reasonably safe.

If you use whatever transformer you have in the junk box then you have no guarantees at all.

I don't know enough about it to tell you how to design one to be safe.