Unlike a standard mechanical switch, the transistor can control the amount of flow by varying the base voltage. I will try to explain transitor's switch function in a very simple manner.
Think of a building with people standing outside (the emitter). The 'base' can be thought of as a door, that when opened, allows the people to move inside (the collector). The wider the door is opened, the more people it will let in;but it takes energy to pull the door open,like someone pulling on it. The same principle applys to the transistor. without energy applied to the base, the door stays shut and the current (the people) can not move from the emitter to the collector. However, as a potential is applied to the base, the door opens. The more potential, the wider the door opens,thus a greater flow of current. In this fashion,transistor act as a switch.
This is also how transistor amplify;by using a small potential at the base, they can move a much larger potential from the emitter to the collector. In essence, you have amplified the small base potential. So, that's it. Pretty simple. eh?