By uniqueness of analytic continuation, $f^2$ is globally a polynomial. Factor $f^2$ into linear factors. Each linear factor must occur to an even power since the zeros of $f^2$ are the same as the zeros of $f$, with twice the order. So $f^2=\lambda\cdot\prod_i(z-z_i)^{2n_i}$
Define $g=f/\prod_i(z-z_i)^{n_i}$. Then $g$ is an entire function and $g^2=\lambda$. There are two possible square roots of $\lambda$, which as a set have the discrete topology, so since $g$ is continuous on all of $\mathbb{C}$, $g$ is constant, taking just one of the square roots of $\lambda$ as it's value. Hence $f(z)=\sqrt{\lambda}\cdot\prod_i(z-z_i)^{n_i}$ is a polynomial.