Is there a smooth or real analytic function $f: \mathbb{R}\to \mathbb{R}$ such that $f(\mathbb{Z})\subseteq \mathbb{Z}$ but $f$ is not a polynomial with integer coefficients?
If the answer is yes we generalize the question as follows:
Is there a smooth or real analytic function $f: \mathbb{R}\to \mathbb{R}$ such that $\forall n \in \mathbb{N} \cup \{0\},\;\;\;f^{(n)}(\mathbb{Z})\subseteq \mathbb{Z}$ but $f$ is not a polynomial with integer coefficients.
In the above by $f^{(n)}$ we mean the $n$th derivative of $f$.
There exists a nontrivial smooth (but not analytic) function that is identically 0 outside of $[1/3,2/3]$. Call this function $\phi$. Then one example is $$ \Phi(x) = \sum_{k\in\mathbb Z}\phi(x-k)$$ with $\Phi^{(n)}(\mathbb Z) = \{ 0 \} \subset \mathbb Z$ for any $n$. Note that the functions that leave $\mathbb Z$ invariant form a vector space, so that if we define $\tilde\Phi$ by
$$ \tilde\Phi(x) = \Phi(x) + x$$ We have also achieved $\tilde\Phi(\mathbb Z) = \mathbb Z$ .
For a non-polynomial analytic answer, consider the function $F(x) := \Gamma(1+x^2)$ with $F(\mathbb Z)\subset \text{Factorial}(\mathbb N^2) \subset \mathbb Z$ and is analytic everywhere.