Before I was a web designer, I was a tattoo artist. This shot is of the very first machine I ever owned during my apprenticeship, many years ago. What you’re looking at is two magnetic coils which (using the power of electricity!) pull down on an armature bar and cause it to vibrate up and down. The needle is attached to the end of the armature bar and it in turn moves up and down through a tube, to keep it stable.
The manufacturing of a tattoo machine is not a science, it’s an art. Every machine is different, every machine has a personality. Some run hot and hard, others run soft and slow. Some change in quality depending on temperature or time used.
Finally, while we’re on the subject, it’s a tattoo machine. Not a “gun”. A gun is a weapon, or an imprecise tool used by amateurs to pierce earlobes.