Why a transistor is used as a amplifier and switch?

transistor has 2 output 1 and 0 so can be used as a switch