How tansistor work as a switch?

Transistors are crucial components in virtually every piece of modern electronics, and are considered by many to be the most important invention of the modern age (as well as a herald of the Information Age).