How can public key not reverse encryption if the algorithm is known? I've been reading about WhatsApp getting "end-to-end" encryption, and when reading about it, I've notice something.

If I want to send a message from cell $A$ to cell $B$, since there's a public key, I will pass my message through this "algorithm" and send to the cell $B$.

My question is, knowing the public key doesn't automatically gives you power to reverse engineer the message sent? How is that possible that knowing the algorithm that created a code and the code itself doesn't get you the original information?
I will give you the simplified answer.

The public key encryption does not prevent adversery from computing private key from public key. It just makes it very very very hard. The algorithms use math that allows simple private->public calculation, but public->private has no good mathematical "shortcuts". It would take adversery more time to calculate this, then for him to walk in front of every home on Earth, and beat every occupant inside with a rubber hose while asking about content of Your message.