I came across Shor's Algorithm (which solves the following problem: "Given an integer N, find its prime factors").
Actually, Shor's algorithm solves the problem "given a periodic function $f$, that is, if $\underbrace{f(f(... f(a))...)}_{k\text{ times}} = a$, what's $k$?"
By specifying $f$ cleverly, we can use this to solve the factorization problem. I note this because it can be used to solve other interesting problems as well.
In any case, what are you really asking is "if we can factor the key, how does that help us break RSA"? Note that relying on the difficulty of factorization what RSA depends on; other methods (such as Diffie-Hellman) are equally vulnerable to Shor's algorithm, but they use a different $f$ function.
Well, with RSA, the public exponent $e$ and the private exponent $d$ are related by $e \cdot d \equiv 1 \pmod{\text{lcm}(p-1, q-1)}$. It turns out that if we know the prime factors $p, q$ and we know the public exponent $e$ (which is given in the public key), it is easy to compute the private exponent $d$; that immediately gives us a way to decrypt via $P = C^d \bmod n$.