Read these two lessons:
В - Russian Prepositions
На - Russian Prepositions

There's no simple explanation because the use of prepositions is often idiomatic. The choice of prepositions is not identical in English and Russian even in simple phrases. For example, in English you can say "in the end" and "at the end" which will be "в конце" in Russian. But you'll get better at picking the right ones with time.

P.S. Funny, you typed the Russian prepositions in Latin letters