Portuguese at one point lost the sound [l] when it appeared between vowels (and in a few other cases). The definite article "o" was originally "lo", and was combined in Old Portuguese with the preposition "per" to make "perlo". When the loss of [l] occurred in the language, the [l] in "perlo" was protected because it was next to the consonant [r] instead of between two vowels. Over time, however, the [r] in this word faded out itself, leaving "pelo" as the modern form, alongside the bare article "o". "Per" was later largely replaced in usage by "por", leaving the three words "por", "o", and "pelo" in concurrent use in the modern language.
All languages continue to change even now, including English and Portuguese. However, the interconnectedness that the internet and globalized communication has brought means that most languages will no longer be fragmenting into daughter languages the way they once did (i.e. how Roman Latin fragmented into the Romance languages). The nature of language evolution has also changed; you can expect a greater convergence of the world's major languages towards one shared pattern (in grammar, pronunciation, and vocabulary) in the coming centuries.
This is called a contraction, whereby the preposition "por" and the following definite articles are fused together, only that it changes a bit:
por + o = pelo por + a = pela
Your intuition was right, only that it doesn't fuse together into poro / pora, but changes into pelo and pela