Recall that when we are factoring a polynomial, we are implicitly finding its roots. By finding a root, we are looking for a value of x (say c) such that p(c) =0. When this happens, our polynomial has the the polynomial (x-c) as a factor.
We are given the values of p at some values of x. We notice that p(5) = 0 and p(-12) =0. So, this means that our polynomial has as a factor the polynomials (x-5) and (x+12).