Since p(3) = 0, this means x = 3 plugs into p(x) to get 0
We can write p(x) as p(x) = (x-3)q(x) where q(x) is some other polynomial that multiplies with (x-3) to lead to x^3-3x^2-x+3
Let's plug in x = 3 and see what happens
p(x) = (x-3)q(x)
p(3) = (3-3)q(3)
p(3) = 0*q(3)
p(3) = 0
No matter what the result of q(3) was, it doesn't matter because it multiplies with 0 to get 0.
The general rule is: if p(k) = 0, then x-k is a factor of p(x). This is a special case of the remainder theorem.