$f(x)=x^2\cos\left(\frac{\pi}{x}\right)$ satisfies the given condition on $\mathbb{N}$, but is not analytic at $x=0$. Its analytic continuation to $\mathbb{C}$ has an essential singularity at $0$.
Since an analytic function is continuous, the Intermediate Value Theorem says that, since $f$ changes sign between $\frac1n$ and $\frac{1}{n+1}$, there is a sequence $\{x_n:\frac{1}{n+1}< x_n<\frac1n\}$ so that $f(x_n)=0$. Since $\lim\limits_{n\to\infty}x_n=0$, the set of zeros of $f$ has $0$ as a limit point. If the set of zeros of an analytic function has a limit point in the domain of said function, the function is identically $0$ on the connected component of that domain containing that limit point.