Ideals are in some sense meant to capture the notion of "multiples" of an element. They originally came in the form of Kummer's ideal numbers. Basically as mentioned above unique factorisation of elements can fail in some rings:
In $\mathbb{Z}[\sqrt{15}]$ we have $10 = 5\times 2 = (5+\sqrt{15})(5-\sqrt{15})$.
Kummer noticed that really the problem is that the ring isn't big enough. It doesn't contain the elements $\sqrt{3}$ and $\sqrt{5}$. If it did then we could explain the two different factorisations as reorderings of things in $\mathbb{Z}[\sqrt{3}, \sqrt{5}]$:
$10 = (\sqrt{5})(\sqrt{5})(\sqrt{5} - \sqrt{3})(\sqrt{5} + \sqrt{3}) = (\sqrt{5})(\sqrt{5} + \sqrt{3})(\sqrt{5})(\sqrt{5} - \sqrt{3})$
From the point of view of $\mathbb{Z}[\sqrt{15}]$ the numbers $\sqrt{3}$ and $\sqrt{5}$ don't exist so Kummer's idea was to in some sense invent them as abstract quantities, rather than having to make a ring extension.
If these abstract quantities were to be invented then they should satisfy the main rules of divisibility.
Dedekind improved on this and invented the notion of ideal of a ring. The axioms for this are exactly the axioms you would expect from divisibility (i.e. in $\mathbb{Z}$ you expect the sum of two numbers divisible by 6 to also be divisible by 6, also you expect ANY multiple of 6 to also be divisible by 6).
He then was able to prove that in some nice rings the ideals factorise uniquely into so called prime ideals...and this uniqueness is upto ordering. This takes into account what we said above, reordering prime ideals gives the two different factorisations. So the idea is not to factorise elements but to factorise the sets of multiples of elements as objects in their own right.
Define prime ideals $\mathfrak{p}_1 = \langle 5, 1+\sqrt{15}\rangle, \mathfrak{p}_2 = \langle 2, 1+\sqrt{15}\rangle, \mathfrak{p}_3 = \langle 2, 1-\sqrt{15}\rangle$.
Then we get:
$\langle 10\rangle = \langle 2\rangle \langle 5\rangle = (\mathfrak{p}_2 \mathfrak{p}_3)(\mathfrak{p}_1^2)$
$\langle 10\rangle = \langle 5+\sqrt{15}\rangle \langle 5-\sqrt{15}\rangle = (\mathfrak{p}_1\mathfrak{p}_2)(\mathfrak{p}_1\mathfrak{p}_3)$
So the two different factorisations of $10$ as an element are explained by two different orderings of the prime ideals.
How does Kummer's ideal numbers tie into all of this? Well you see we had to use ideals generated by more than one element...these are corresponding to "multiples" of elements that don't exist in the ring!