Note that $(x+a)(x+b) = x^2+(a+b)x+ab$. So, the coefficient of $x$ is the sum of the two numbers we want to find, and the constant term is their product. So when we see a quadratic polynomial like $x^2-3x+2$, we have to try and find two numbers which add up to $-3$ and multiply out to $2$. The numbers we get are $-1$ and $-2$, and so the factorization of $x^2-3x+2$ (that's what it's called) is $(x-1)(x-2)$.
As another example, try factorizing the following: $x^2-x-6$. That is, find two numbers which multiply to $-6$ and add up to $-1$. The answer is below.
Factorization is harder when the leading coefficient (that is, the coefficient of $x^2$) is not $1$, as the above method doesn't work. Consider, for example, the polynomial $3x^2-7x+2$. Here's a fun method for factoring these. First, make sure you factor out any constants that can be factored out (e.g. if given the polynomial $4x^2-10x+4$, you would want to factor out the $2$ to obtain $2(2x^2-5x+2)$, and then perform the following process on the non-constant factor).
Using the example of $3x^2-7x+2$, take the leading coefficient out and multiply it into the constant term to give us $x^2-7x+6$. Now use the above method to factor this polynomial as $(x-1)(x-6)$. Remember that $3$ we took out of the leading term? Put it as the denominator of the constant terms to give us $\left( x-\frac 1 3\right)\left(x - \frac 6 3\right)$. Now, reduce the fractions to get $\left( x-\frac 1 3\right)\left(x-\frac 2 1\right)$. Finally, put whatever is in the denominators next to the $x$ term in each factor, giving us the final answer of $(3x-1)(x-2)$.