How does passing to ideals solve the problem of unique factorization? $A:=\mathbb{Z}[\sqrt{-5}]$ is not a UFD, because for instance
$$21 = 3 \cdot 7 = \left( 1+2\sqrt{-5}\right) \cdot  \left(1-2\sqrt{-5}\right).$$
But since $A$ is a Dedekind domain, we should have unique factorization of ideals into prime ideals (this is, after all, the whole point of introducing Dedekind domains). But is it not the case that the ideals $(3)$,$(7)$,$\left( 1+2\sqrt{-5}\right)$,$\left( 1-2\sqrt{-5}\right)$ are all different prime ideals and that 
$$(21) = (3) \cdot (7) = \left( 1+2\sqrt{-5}\right) \cdot  \left(1-2\sqrt{-5}\right)?$$
What am I missing?

$3, 7, 1 + 2\sqrt{-5}$, and $1 - 2\sqrt{-5}$ are irreducible elements of $A$, but not prime elements. Hence the principal ideals generated by these aren't prime ideals. The prime ideals dividing these principal ideals are not principal, they are generated by two of these irreducible elements. We have
$$(21) = (3, 1 + 2\sqrt{-5})\cdot (3, 1 - 2\sqrt{-5})\cdot (7, 1 + 2\sqrt{-5})\cdot (7, 1 - 2\sqrt{-5})\,.$$
