I know, this sounds like a simple question. I can't comprehend it. No one body that is. Except maybe Cecil. Here's how it works.
Somebody builds a machine.
Once somebody built a machine that could do all that, somebody else came along and programmed it to behave like a similar, but more complex machine. The process repeats until what you see on your desk is a machine that's good for nothing but displaying the guts of the bad guys spattered all over a virtual wall. I don't blame you. What you really need to know is how the bottom layer, the hardware, works. At the bottom are the electronics.