Which are main purposes of bipolar transistors?
I don't get it how can it be used for example as a switch


You need to think about the voltage "lost" from collector and emitter when connected to a load: -



Take the magenta curve - base current is 62 uA and, if the collector current was (say) 10 mA the volt drop across collector and emitter is about 200 mV.

You might say "that's not much of a switch" and you'd be somewhat correct. A BJT is an imperfect switch but, if you want to control a load resistor of 1 kohm on a 10 V supply, then using a BJT will allow 9.8 volts (in this example) to be supplied to the load.

So, you could force more base current in and you would get a smaller volt drop for the same load current. Some transistors will allow over 50 mA base current and can control over an amp with a small volt drop. Darlington transistors "lose" about 0.7 volts but can control tens of amps typically.

So, a BJT is imperfect as a closed contact but, it's pretty good as an open contact i.e. it can switch the load off with only the odd micro-amp still flowing. If you can live with 200 mV "lost" then it's a switch!

Maybe this website will help a bit more.

If you really want a better switch then use a MOSFET - good MOSFETs these days are capable of dropping only a few milli-volts with a 10 amp load.