I was reviewing verbs of motion and came accross the following sentences from previous posts.

Я пойду в магазин, пока! – I will go to the store, bye!
Я пойду в кино в 4 часов - I will be going to the cinema at 4 pm
Мне надо пойти на почту – I need to go to the post office
Мы пошли на похороны - We went to the funeral
Он пошёл на дискотеку - he went to the discotec

Sometimes в is used and sometimes на is used.

What is the rule?

Thanks is advance.