Transistors function by regulating the flow of electrical current through them. They have three layers of semiconductor material, typically composed of silicon. These layers are called the emitter, base, and collector. By applying a voltage to the base, the transistor can control the current flowing between the emitter and collector, enabling it to act as a switch or amplifier.