Let us present an organised argument for this otherwise elementary statement. Let us write $\mathbb{P}$ for the set of all strictly positive prime integers (in other words, the set of nonzero prime natural numbers) and for arbitrary integer $n \in \mathbb{Z}$ let us define $\Pi(n)\colon =\{p \in \mathbb{P} \mid p \mid n\}$ to be the set of all natural prime divisors of $n$. It is an elementary exercise to establish the fact that the relations $m \mid n \Rightarrow \Pi(m) \subseteq \Pi(n)$ respectively $\Pi(mn)=\Pi(m) \cup \Pi(n)$ take place for arbitrary integers $m, n \in \mathbb{Z}$. Note that the latter property can be expressed by saying that the map $\Pi \colon \mathbb{Z} \to \mathscr{P}\left(\mathbb{P}\right)$ is a morphism between the monoids $(\mathbb{Z}, \cdot)$ and $\left(\mathscr{P}(\mathbb{P}), \cup\right)$.
Furthermore, for fixed $p \in \mathbb{P}$ let us introduce the map:
\begin{align}
&v_p \colon \mathbb{Z}^{\times}(=\mathbb{Z}\setminus\{0\}) \to \mathbb{N} \\
&v_p(n)\colon =\max\left\{k \in \mathbb{N} \mid p^k \mid n\right\}
\end{align}
and remark that $v_p(mn)=v_p(m)+v_p(n)$ for any two nonzero integers $m, n \in \mathbb{Z}^{\times}$ (in other words, $v_p$ is a morphism between the monoids $\left(\mathbb{Z}^{\times}, \cdot\right)$ and $(\mathbb{N}, +)$).
Let us also recall the fundamental theorem of arithmetic under the formulation that for every $n \in \mathbb{Z}^{\times}$ one has the relation $n=\mathrm{sgn}(n)\displaystyle\prod_{p \in \mathbb{P}}p^{v_p(n)}=\mathrm{sgn}(n)\displaystyle\prod_{p \in \Pi(n)}p^{v_p(n)}$, where $\mathrm{sgn} \colon \mathbb{Z} \to \{-1, 0, 1\}$ is the sign function of the totally ordered ring $\mathbb{Z}$. We also point out the important relation $m \mid n \Leftrightarrow (\forall p)\left(p \in \mathbb{P} \Rightarrow v_p(m) \leqslant v_p(n)\right)$, valid for arbitrary nonzero integers $m, n \in \mathbb{Z}^{\times}$.
Consider now a fixed natural number $n \in \mathbb{N}$ and write for simplicity $\mathbb{Z}_n\colon =\mathbb{Z}/n\mathbb{Z}$. Furthermore, for arbitrary integer $m \in \mathbb{Z}$ let us denote the residue class of $m$ modulo $n$ by $\overline{m}$. Assuming that $m \in \mathbb{Z}$ is such that $\overline{m} \in \mathrm{Nil}\left(\mathbb{Z}_n\right)$ we infer the existence of $k \in \mathbb{N}^{\times}$ such that $\overline{m}^k=\overline{m^k}=\overline{0}$. This entails $n \mid m^k$ and by virtue of the relations mentioned in the previous paragraph entails $\Pi(n) \subseteq \Pi\left(m^k\right)=\Pi(m)$ (the fact that $k\neq 0$ is required to make the latter relation of equality valid).
Conversely, assuming that the integer $m \in \mathbb{Z}$ satisfies the relation $\Pi(n) \subseteq \Pi(m)$ we infer that $p \mid m$ for each $p \in \Pi(n)$ and since two distinct primes are mutually prime we infer from an elementary proposition in arithmetic that $r\colon=\displaystyle\prod_{p \in \Pi(n)} p \mid m$. If $\Pi(n)=\varnothing$ we infer - in conjunction with $n \in \mathbb{N}$ - that $n=1$ and thus $\mathbb{Z}_1=\left\{\overline{0}\right\}$ is a null ring, all of its elements - $\overline{m}$ in particular - thus being nilpotent. If on the other hand $\Pi(n) \neq\ \varnothing$, since nonempty totally ordered sets have maxima we can in particular consider $h=\displaystyle\max_{p \in \Pi(n)}v_p(n)$. Since in general $p \in \Pi(m) \Leftrightarrow v_p(m)>0$ for any prime $p \in \mathbb{P}$ and integer $m \in \mathbb{Z}$, we ascertain that $h>0$. Since by construction $v_p(n) \leqslant h=v_p\left(r^h\right)$ is valid for each $p \in \Pi(n)$ (and therefore automatically for any $p \in \mathbb{P}$), it follows that $n \mid r^h \mid m^h$, which signifies that $\overline{m^h}=\overline{m}^h=\overline{0}$. As $h>0$, we conclude that $\overline{m} \in \mathrm{Nil}\left(\mathbb{Z}_n\right)$.