First, when talking about polynomials, it is important to be clear about where the coefficients come from. Everything I'm about to say about polynomials is true if the coefficients are integers, rational numbers, real numbers, or complex numbers. In fact, if the coefficents come from $R$, then everything I'm about to say about polynomials is true as long as $R[x]$ is a unique factorization domain.
Second, as user Lulu pointed out, if $a=b$, then the claim is false. Let $p(x)=x-1$, and let $a=b=1$, then both $x-a$, $x-b$ divide $p(x)$, but $(x-a)(x-b)$ does not divide $p(x)$.
If $a\ne b$, and $x-a$, $x-b$ both divide $p(x)$, then $(x-a)(x-b)$ divides $p(x)$ as well. We can show this by using the following useful lemma:
Lemma: Let $f(x)$, $p(x)$, $q(x)$ be polynomials, and suppose $f(x)$ is irreducible. If $f(x)$ divides $p(x)\cdot q(x)$, then either $f(x)$ divides $p(x)$ or $f(x)$ divides $q(x)$.
Side comment: Irreducible polynomials are a lot like primes. Note that for integers $p$, $a$, $b$, with $p$ prime, if $p$ divides $ab$ then either $p$ divides $a$ or $p$ divides $b$.
Proof of Original Claim: Let $a\ne b$ and let $x-a$, $x-b$ divide $p(x)$. Our goal is to show that $(x-a)(x-b)$ divides $p(x)$.
Since $x-a$ divides $p(x)$, we have that $p(x)=(x-a)q(x)$ for some polynomial $q(x)$. Since $x-b$ divides $p(x)$, it divides $(x-a)q(x)$. The fact that $x-b$ is degree $1$, means that $x-b$ is irreducible. So either $x-b$ divides $x-a$ or $x-b$ divides $q(x)$. The fact that $a\ne b$ means that $x-b$ cannot divide $x-a$, so it must divide $q(x)$. So $q(x)=(x-b)r(x)$ for some polynomial $r(x)$ and $p(x)=(x-a)(x-b)r(x)$. $\square$