How does passing to ideals solve the problem of unique factorization?
$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})\,.$$
Looks like you know what principal ideals are, but let's review that anyway. Given a number $n$ in a given ring $R$, the principal ideal $\langle n \rangle$ consists of all numbers of the form $mn$, with $m \in R$ also. In other words, the ideal $\langle n \rangle$ is simply the set of all multiples of the number $n$ in the ring $R$.
You might have read in books and on this site that ideals are "linear combinations" but no one explains what the hell that means. An ideal, not necessarily principal, $\langle n, u \rangle$ consists of all numbers of the form $mn + uv$. Of course $u$ and $v$ are also numbers in the relevant ring $R$.
Let's go back to good old $\mathbb Z$ for a moment. Consider $\langle 4 \rangle$. That's just all multiples of 4, the doubly even numbers. Now consider $\langle 4, 14 \rangle$. That's all numbers of the form $4m + 14v$. Clearly $\langle 4 \rangle \subset \langle 4, 14 \rangle$ and $\langle 14 \rangle \subset \langle 4, 14 \rangle$.
So $\langle 4, 14 \rangle$ contains all multiples of 4 and also all multiples of 14. But it also contains numbers that are the sum of a doubly even number and a multiple of 14, numbers like 18, 22, 26, 30, 34, 38, or $-458, - 454, -450$, etc.
In fact, as it turns out, $\langle 4, 14 \rangle$ contains both doubly even numbers and singly even numbers. What's more, $\langle 4, 14 \rangle = \langle 2 \rangle$. As you know, $\mathbb Z$ is a principal ideal domain. All ideals in a principal ideal domain, regardless of how they are presented, are principal ideals.
Big deal, who cares. Let's go back to $\mathbb Z[\sqrt{-5}]$. As you've already discovered, $$21 = 3 \times 7 = (1 - 2 \sqrt{-5})(1 + 2 \sqrt{-5}).$$ It gets even "worse" than that: $$(4 - \sqrt{-5})(4 + \sqrt{-5}) = 21$$ also.
Clearly the purely real numbers 3 and 7 are irreducible but not prime, and the same goes for the complex numbers mentioned so far.
So if $p$ is an odd prime in $\mathbb Z$ but not in $\mathbb Z[\sqrt{-5}]$, how do you factorize the ideal $\langle p \rangle$? One way, taken from the already classic Alaca and Williams text, is $$\langle p \rangle = \langle p, x - \sqrt{-5} \rangle \langle p, x + \sqrt{-5} \rangle,$$ where $x \in \mathbb Z^+$ is the smallest solution to $x^2 \equiv -5 \pmod p$.
Hence, $$\langle 3 \rangle = \langle 3, 1 - \sqrt{-5} \rangle \langle 3, 1 + \sqrt{-5} \rangle$$ and $$\langle 7 \rangle = \langle 7, 3 - \sqrt{-5} \rangle \langle 7, 3 + \sqrt{-5} \rangle.$$ Then the factorization of $\langle 21 \rangle$, in what I consider to be its canonical form, is $$\langle 3, 1 - \sqrt{-5} \rangle \langle 3, 1 + \sqrt{-5} \rangle \langle 7, 3 - \sqrt{-5} \rangle \langle 7, 3 + \sqrt{-5} \rangle.$$
By mixing and matching generators of these ideals, we can obtain different factorizations of 21 as a number. For example, given that $-7 + 2 \sqrt{-5} \in \langle 3, 1 - \sqrt{-5} \rangle$ and $11 - 6 \sqrt{-5} \in \langle 7, 3 + \sqrt{-5} \rangle$ (assuming I haven't made mistakes with any of the signs), we have $$4 + \sqrt{-5} \in (\langle 3, 1 - \sqrt{-5} \rangle \langle 7, 3 + \sqrt{-5} \rangle).$$
I leave it an an optional exercise to figure out which ideals $1 + 2 \sqrt{-5}$ comes from and how.
By bypassing the problems of signs and quadrants, to identify the unique origins of multiple distinct factorizations.
Even in $\textbf{Z}$ we have the problem of signs. How, for example, do you factorize $-30$? A computer program like Mathematica says $-1 \times 2 \times 3 \times 5$, but by the caveats of the fundamental theorem of arithmetic, $-2 \times -3 \times -5$ is also a valid factorization.
But with ideals, it's just $\langle 2 \rangle \langle 3 \rangle \langle 5 \rangle$ and we can add minus signs to any of those generators and it doesn't make a difference.
And then when we get to $\textbf{Z}[\sqrt{-5}]$, we're neither concerned with which quadrant of the complex plane a number is nor the quadrant of its ideals' generators, since they're all included, e.g., $-4 + \sqrt{-5} \in \langle$