Do is found in all the Slavic languages as a preposition with the meanings “[up] to” and “before”. In all the Slavic languages which have cases, this preposition governs only the genitive case, so it's not just a Polish phenomenon, the reasoning of this fact lying somewhere about 15 centuries ago when the Slavic languages split from Proto-Slavic.
I don't know the exact historic reasoning, but I can suggest a rather logical practical way to explain the genitive case usage with this preposition, a way for an English-speaking learner to understand and memorize it.
There are 3 similar prepositions in Polish that govern the genitive case, blisko “near”, do “to”, and od “from”. For my explanation, we need to slightly re-analyze their meanings. Originally, blisko (+ gen.) is “near”, e.g. blisko sklepu “near [the] store”. But let's assume blisko means “in-the-outskirts”, "in-the-vicinity", and assume the following genitive case means “of-”, then blisko sklepu comes to look like “in-the-vicinity of-[the]-store”, which is pretty English and quite logical. Similarly, do means “to-the-vicinity”, so do sklepu is “to-the-vicinity of-[the]-store”. And od means “from-the-vicinity”, so od sklepu is “from-the-vicinity of-[the]-store”.
There's one more Polish locative preposition with genitive, z “from”, but it's not “from-the-vicinity” like od, it's “from-the-inside” ~ “from-the-interior”, so z Polski is “from-the-inside of-Poland”.
With a little bit of imagination one can find quite plausible justification practically for everything. Even if it wasn't like that historically, the pattern I suggest is quite productive. Mind, my explanation is for aligning the Polish cases with the English lack thereof, but it can also be aligned with other languages, with little effort.