Yep, as cellocase said, all there is to it is to factorise and cancel out the common factors.

And, just in case you don't know how to factorise quadratics...
Let's say you have an expression x^2 + bx + c.
You want to turn it into the form (x + d)(x + e).
If we multiplied out the brackets, you get x^2 + (d+e)x + de.
Thus x^2 + bx + c = x^2 + (d+e)x + de
So we can see that the two numbers 'd' and 'e' should add together to make 'b', and multiply together to make 'c'.
----------------------------------------------------------
So, as an example, if you had x^2 - 2x - 8...
What pair of numbers can multiply together to make -8? One must be negative and one must be positive, otherwise you wouldn't have a negative sign. The only factors of 8 are 1, 2, 4 and 8. Hence, the factors of -8 are -1 & 8, 2 & -4, -2 & 4 or 1 & -8.
From these pairs of factors, is there a pair where you can add them together to make -2? The only possible combination would be 2 and -4.
So x^2 - 2x -8 = (x + 2)(x - 4).
You can multiply out the brackets to check that they are indeed equivalent.
-----------------------------------------------------------
You can apply this idea to the two quadratics in your question. For x²+4x-21, you find two numbers that multiply together to make -21, and two that add together to make 4. You should be able to work out what to do with x²-9x+18. From there, just follow what cellocase said!
~Wobby~