Let $p(x),q(x)$ be two polynomials over a field $F$ such that $p(a)=q(a)$ for all $a\in F$. Can we say that always $p(x)=q(x)$?
If $F=\mathbb Z_5$, then it is possible to find examples of $p(x)\neq q(x)$ but $p(a)=q(a)$ for all $a\in \mathbb Z_5$. Is it possible to have such polynomials over an infinite field?
If $\mathbb{F}$ is finite, then the answer is negative. Take $\mathbb{F} = \mathbb{Z}_2$, for example, and consider the polynomial $f(x) = x(x + 1) = x^2 + x$, we certainly have $f(x) = 0, \forall x \in \mathbb{Z}_2$; but $f \neq 0_{\mathbb{Z}_2[x]}$. I'll leave the case $\mathbb{F} = \mathbb{Z}_5$ for you to ponder.
If $\mathbb{F}$ is infinite, then the answer is indeed positive. I'll prove the following claim, and your problem is just a corollary of it (let's see if you can figure it out).
Claim
Proof
Assume that $f \neq 0$, and let $n = \deg(f)$.
If $n = 0$ (i.e, $f$ has degree 0), then $f = \beta \in \mathbb{F}$, and for $f(0)$ to be 0, we must have $\beta = 0$, hence $f = 0$ (contradiction).
If $n \neq 0$, we then choose $n$ arbitrary distinct element(s) of $\mathbb{F}$, i.e $x_1; x_2; ...; x_n$. Since we have $f(x_i) = 0, \forall 1 \le i \le n$, using long polynomial division, we can obtain $f(x) = a(x - x_1)(x - x_2)(x - x_3)...(x - x_n)$, for some $0 \neq a \in \mathbb{F}$ (since, we are assuming that $f \neq 0$).
Now, since $\mathbb{F}$ is infinite, we can choose another $\alpha \in \mathbb{F}$, such that it's different from all $n$ elements we chose above, so $f(\alpha) = a(\alpha - x_1)(\alpha - x_2)(\alpha - x_3)...(\alpha - x_n) \neq 0$, which is a contradiction (since we must have $f(x) = 0, \forall x \in \mathbb{F}$). Hence $f = 0$.