Let us prove, for example, that the square root of 6 is irrational.
Suppose the square root of 6 were p/q, where p and q are integers.
Then 6=p^2/q^2 (the notation "^2" means squared), so
p^2 = 6 q^2.
The argument uses the factorization into primes of both sides of this equality, so we must write it as
p^2 = 2 x 3 x q^2.
This seems to say that the integer on the left equals the integer on the right, but that is impossible. We just have to ask how many times the integer 2 occurs as a factor on the left, and also on the right. The observation is the same as before. 2 occurs an even number of times on the left and an odd number of times on the right (an even number of times in q^2, and then there is one more 2 coming from 2 x 3). The supposition that such integers p and q exist was wrong.
Now let us see what goes wrong with the argument if we try to prove, for example, that the square root of 9 is irrational. This would be crazy, because the square root of 9 is 3, which is an integer. Just as before we suppose that the square root of 9 were a ratio p/q, with p and q integers. Then, squaring we would have
9 = p^2/q^2
p^2 = 9 q^2
or, factoring into primes,
p^2 = 3 x 3 x q^2.
We ask how many times 3 occurs as a factor on the left side and on the right side, but now it is an even number of times in each case. That is perfectly possible -- no inconsistency there. So the proof doesn't work to prove square root of 9 irrational.