I'll show you a similar example: Given (x + a)(x + 1) = x^2 + 3x + 2, find a.

Expanding out the right hand side, we get

(x + a)(x + 1) = x^2 + ax + x + a = x^2 + (a+1)x + a

Since we were given (x + a)(x + 1) = x^2 + 3x + 2, we now have

x^2 + (a+1)x + a = x^2 + 3x + 2

But if these two expressions are equal, then the x^2 terms must be the same (which they are). Also, the x terms must be the same. This means that a + 1 = 3, or a = 2. We can check the constant term is the same as well, where we see again that a = 2.