ZU is a DATIV preposition that can be used in different situations but since you’re asking about ZUR/ZUM I assume you’re confused about its use as a local preposition.
Firstly, you have to know that a preposition is never used alone in German. It always has a companion which can be e.g. the article DER/DIE/DAS of the substantive it's being used with. And since every preposition expresses a specific case (DATIV / GENITIV / AKKUSATIV), its companion (for example the article DER/ DAS / DIE) will have to be "declined" (dekliniert).
e.g.
Ich gehe zum Arzt = Ich gehe zu dem Arzt.
Substantive = Arzt , Article = DER, because the preposition is ZU you have to „decline“ it to DATIV, which is DEM.
You do the same with the other articles.
What happens is that prepositions and articles are often turned into one single word.
ZU + DEM = ZUM
ZU + DER = ZUR
Just to refresh your memory, when talking about local prepositions you need to know that they are prepositions that give answers to the questions WO (where), WOHIN (where to), and WOHER (from where). ZU answers the question WOHIN because it normally expresses a relocation and/or it specifies a target destination.
Examples:
- Wohin gehst du?
- Ich gehe zur Schule / zur Bank / zu der Party / etc.
- Ich gehe zum zum Mark / zum Bäcker / zum Metzger/ zum Frisuer/ etc.
The preposition ZU answer the question WO as far as I remember only when you say ZU HAUSE (e.g. ich bin zu Hause)
NOTE: A few prepositions (an, auf, hinter, in, neben, über, unter, vor, zwischen) can vary from DATIV to AKKUSATIV. They are called Wechselpräpositionen. For you to understand it better I'd recommend you to check and practice which prepositions are used with which case and how to decline articles.
I hope it helped and good luck!