I think the proposer tried to say that *if for every integer $n$ there is an integer $m$ such $f(n)=m^2$, then $f(x)=g(x)^2\dots$*.

The generalization from exponent $2$ to higher exponents $e$ is an exercise in the second volume of the classical Polya/Szegö problem book. I don't have it at hand now, so I cannot give a more precise reference.

If one allows more sophisticated tools, then it follows immediately from Hilbert's irreducibility theorem: Let $t$ be another variable, and factorize $f(x)-t^e$ over $\mathbb Q(t)$ into irreducible factors $P_i(t,x)$. By Hilbert, there are infinitely many integers $n$ such that $P_i(n,x)$ is irreducible for all $i$. On the other hand, $f(x)-n^e$ has an integral root for each $n$. Thus there is an index $i$ such that $P_i(t,x)$ has degree $1$ with respect to $x$, so $f(x)-t^e$ has a root in $\mathbb Q(t)$. Gauss' lemma yields that this root is in $\mathbb Q[t]$, so $f(t)=g(t)^e$ for a polynomial $g$ with rational coefficients. One quickly gets that the coefficients of $g$ then are indeed integers.