Two polynomials have the same value at every real number if and only if they are identical (exact same coefficients in each and every power of $x$); this follows because a polynomial of degree $n\gt 0$ can have at most $n$ roots. If $f(x)$ and $g(x)$ are the same at every value of $x$, then $f-g$ has infinitely many roots, and so must be the zero polynomial.
So write $f(x) = a_nx^n+a_{n-1}x^{n-1}+\cdots+a_1x + a_0.$
Then $\begin{align*} f(-x) &= a_n(-x)^n + x_{n-1}(-x)^{n-1} + \cdots + a_1(-x) + a_0\\ &= a_n (-1)^nx^n + a_{n-1}(-1)^{n-1}x^{n-1} + \cdots + a_1(-1)x + a_0\\ &= \left((-1)^na_n\right)x^n + \left((-1)^{n-1}a_{n-1}\right)x^{n-1} + \cdots + \left(-a_1\right)x + a_0. \end{align*}$
Now, $f(x)$ is even if and only if $f(x) = f(-x)$. That means that we need $a_nx^n+a_{n-1}x^{n-1} + \cdots + a_1 x + a_0 = (-1)^nx^n + (-1)^{n-1}a_{n-1}x^{n-1}+\cdots +(-a_1)x + a_0.$ That, in turn, means we need $a_n = (-1)^{n}a_n,\quad a_{n-1}=(-1)^{n-1}a_{n-1},\ldots,\quad a_1 = -a_1, \quad a_0=a_0.$
If $k$ is even, then $(-1)^k = 1$, so we automatically get $a_k=(-1)^ka_k$; that just says we need $a_k=a_k$, which is always true. If $k$ is odd, then $(-1)^k = -1$, so we need $a_k=-a_k$. This can only happen if $a_k=0$.
So $f(x)$ is an even function exactly when all odd terms to have coefficient $0$. So it must be a polynomial in which the only powers of $x$ that "show up" are even powers of $x$ (including $x^0$ which gives the constant term).
For $f(x)$ to be an odd function, we need $-f(x)=f(-x)$. That means that we need: $-\Bigl(a_nx^n+a_{n-1}x^{n-1} + \cdots + a_1 x + a_0\Bigr) = (-1)^nx^n + (-1)^{n-1}x^{n-1}+\cdots +(-a_1)x + a_0.$ That, in turn, means we need $-a_n = (-1)^{n}a_n,\quad -a_{n-1}=(-1)^{n-1}a_{n-1},\ldots\quad, -a_1 = -a_1, \quad -a_0=a_0.$ This time, if $k$ is odd, then we are asking for $-a_k = -a_k$ to be true, which it always is; and if $k$ is even we are asking for $-a_k = a_k$, which is true if and only if $a_k=0$.
So $f(x)$ is an odd function exactly when all the even coefficients are zero; that is, the only powers that "show up" are odd powers of $x$.