A bipolar junction transistor (BJT) is a sandwich of three doped semiconductor layers: N-P-N for an NPN transistor. The middle layer, the base, is made very thin and lightly doped so that charge carriers can cross it.
NPN transistor: layers, biasing and switching regionsWhen the base-emitter junction is forward biased past its 0.7 V knee, a small current IB flows into the base. Because the base is thin, almost all the injected electrons get pulled across into the collector, so the collector current equals beta times the base current: IC = beta x IB while the transistor stays active.
The transistor is a switch in three regions. In cut-off, IB = 0 and no collector current flows - off. In the active region, IC = beta x IB, so a small base signal controls a large collector current - amplification. In saturation, the load resistor caps IC and V_CE collapses to about 0.2 V - fully on.
The two-bit engine
Every digital gate in a CPU is built from transistors used as switches that slam between cut-off and saturation. Billions of these on/off states per second are how a computer computes.