A transistor is fundamentally a tiny switch with three pins. When a logical 1 is applied to the control pin the switch is closed connecting in to out.