The transistor is a switch that can be operated by applying a small voltage to one of the legs, causing another leg to "open" or "close". Which leg does what depends on the type of transistor, which can be found in the datasheet. Transistors can be influenced by ambient temperature[^touch], and therefore are usually placed in pairs to cancel each other out. Next to switching, transistors can also be used to amplify signals.
Transistors come in many shapes and sizes. Some are meant to dissipate heat, and are connected to a heatsink, they are ususally near a power source.