I'm not too sure if this is the correct site for this but anyway, I heard that whenever a computer program is compiled, it is turned into 0s and 1s. But how does a computer recognize 0s and 1s? A computer is electrical and electricity can't read. So how does a computer read 0s and 1s?
When people say 1s and 0s, what we're really referring to are logic levels, where a 0 refers to a 'low' level and a 1 refers to a 'high' level. Since these are just voltage levels, the computer can recognize and operate on these natively.
Also, a computer program is usually stored as 0s and 1s before compiling as well, as everything on your computer will be stored that way. However, after compiling, you will get a file filled with what is called machine code. Machine code is a list of binary instructions (as opposed to text like the original source code) that can be directly interpreted by the circuitry in the processor.
Edit: adding more details as comments are too short. Let's say you have a program sitting in RAM. The RAM in your computer is called DRAM. A DRAM 'cell' holds one 'bit' of information, either a 0 or a 1. A DRAM cell consists of a single transistor and a single capacitor. The transistor can be turned on to enable access to the capacitor, either to charge it up and store a 1, discharge it and store a 0, or read the stored charge. A modern DRAM chip will have several billion of these cells, along with address demultiplexers, sense amplifiers, bus interface circuitry, auto-refresh timers, etc. The DRAM chip is connected to the processor with two wide parallel buses and some control lines. The buses are the address bus and the data bus. The address bus tells the memory chip which cells to access, and the data bus carries the data in the appropriate direction. Each bus is simply a bunch of wires in parallel, and each wire can be set to either a 'high' level or a 'low' level. These generally correspond to the power supply levels. For example, DDR2 SDRAM uses an IO standard called SSTL_18, which defines a 'zero' as 0 volts and a 'one' as 1.8 volts. Anyway, your program will be stored across a sequence of these cells in a DRAM chip. In a DRAM cell, a 1 corresponds to a cell with a charged capacitor, and a 0 corresponds to a cell with an empty capacitor. To read out the contents of the memory, the processor drives an address onto the address bus and sets the control lines to instruct the logic in the DRAM chips to read out the data at that address. The logic in the DRAM chip will connect the particular cells to the sense amplifiers and read out the charge stored in them. These levels will then be driven out of the DRAM chips on the data bus towards the CPU. The CPU will read in the voltage levels on the data bus with input buffers, adapting the voltage from the memory bus voltage to the internal CPU core voltage. Once inside the CPU core, the data will most likely be written into an SRAM based cache memory. SRAM stores each data bit in SRAM cells that generally consist of 6 transistors. Once the CPU is ready to execute the code, it will be copied out of the cache memory and onto an internal instruction bus. Logic inside the CPU will then interpret the pattern of bits on the bus and then perform the required actions to execute the instruction.
When HUMANS look at ones and zeros, we see "1" or "0" on a screen, or printed on paper, or even as a LED that is dark or lit. But what a COMPUTER "sees" as a logical zero is zero volts, and a logical one as some predetermined voltage like 5V. (Lower in modern CPUs, etc. but never zero.)
In exactly the same manner as a light switch on the wall. A HUMAN sees the light switch physically in one position or the other, but the light either "sees" the mains power and lights up, or it "sees" zero power and cannot light up.
You say "it is impossible to program a voltage". But that is not correct. That is EXACTLY what you are programming. It comes down to 0V (logic zero) or 5V (logic one).
Transistors can be used two ways, we know about them being able to amplify things, feed in a signal of voltage X you get "out" a signal of voltage X*Y. But that is the linear region. It can only go as high or as low as the power supply or voltage rails. So you can also use them as switches, forcing them through the linear region and slamming into either the high or low rail. Take a couple transistors, add some other elementary components and you can electrically build AND, OR, NOT, etc circuits. And from that you can wire up any kind of boolean equation you want. Now take things that oscillate, crystals or just using the nature of the speed of the electrons through a material and feedback, you can create a "one", "zero", "one"..."clock". feed the clock into the boolean equations and you can build computers. Play with feedback some more and/or take advantage of electrical components like capacitors or magnetics and you can store ones and zeros to be retrieved later. The storing and retrieving are nothing more than boolean equations built by elementary logic gates made up of transistors and other elementary components.