You a looking for the number of $k$-potent elements of the ring $\mathbb{Z}[i]/(n)$.
If $n=p_1^{r_1}\cdots p_s^{r_s}$ is the prime factorization of $n$, then by the Chinese Remainder Theorem the ring splits as a product
$$\mathbb{Z}[i]/(n)=\mathbb{Z}[i]/(p_1^{r_1})\times \cdots \times \mathbb{Z}[i]/(p_s^{r_s})$$
and the number of $k$-potent elements in a product of rings is clearly the product of the number of $k$-potent elements in each factor, so it suffices to treat the case $n=p^r$. The analysis is then different depending on the splitting of $p$ in $\mathbb{Z}[i]$.
Case 1 : $p\equiv 1 \pmod{4}$
In this case, $(p)$ splits as a product of two primes $(p)=\mathfrak{p}_1\mathfrak{p}_2$ in $\mathbb{Z}[i]$ and the residue class degree $f$ is $1$. Hence $$\mathbb{Z}[i]/(p^r)=\mathbb{Z}[i]/\mathfrak{p}_1^r \times \mathbb{Z}[i]/\mathfrak{p}_2^r$$ and, since $f=1$, the extension of local fields $\mathbb{Q}[i]_{\mathfrak{p}_j} /\mathbb{Q}_p$ has degree $1$, so
$$\mathbb{Z}[i]/\mathfrak{p}_j^r\cong \mathbb{Z}[i]_{\mathfrak{p}_j}/\mathfrak{p}_j^k \cong \mathbb{Z}_p/(p)^r = \mathbb{Z}/p^r\mathbb{Z}.$$
A $k$-potent element $x$ in $\mathbb{Z}/p^r\mathbb{Z}$ is clearly either $0$ or a unit (in which case $x^{k-1}=1$). The group of units $\mathbb{Z}/p^r\mathbb{Z}$ is known to be cyclic of order $p^{r-1}(p-1)$, so the number of elements $x$ such that $x^{k-1}=1$ is $\gcd(k-1,\ p^{r-1}(p-1))$.
Hence the number of $k$-potent elements in $\mathbb{Z}[i]/(p^r)$ is
$$(\gcd(k-1,\ p^{r-1}(p-1))+1)^2$$
Case 2 : $p\equiv 3 \pmod{4}$
In this case $(p)$ is inert in $\mathbb{Z}[i]$ and the completion $\mathbb{Q}[i]_{(p)}$ is equal to $\mathbb{Q}_p[i]$ (which is unramified over $\mathbb{Q}_p$).
We have
$$\mathbb{Z}[i]/(p^r)=\mathbb{Z}_p[i]/(p^r)$$
and, again, all $k$-potent elements are either zero or units $x$ such that $x^{k-1}=1$. In this case, the group of units is
$$(\mathbb{Z}_p[i]/(p^r))^\times \cong \mathbb{Z}_p[i]^\times/U^{(r)} \cong \mu_{p^2-1} \times U^{(1)}/U^{(r)}$$
where $\mu_{p^2-1}$ is the group of $p^2-1$-th roots of unity and $U^{(m)}=1+(p^m)$ (see Neurkich ANT chapter 2 for these results). The logarithm and exponential functions define an isomorphism
$$U^{(1)}/U^{(r)}\cong p\mathbb{Z}[i]/p^r\mathbb{Z}[i] \cong \mathbb{Z}[i]/p^{r-1}\mathbb{Z}[i] \cong (\mathbb{Z}/p^{r-1}\mathbb{Z})^2$$
Hence the number of $k$-potent elements is
$$\gcd(k-1,\ p^2-1) \gcd(k-1,\ p^{r-1})^2 + 1$$
The remaining case is $p=2$, which is slightly more annoying to treat because of ramification but should be doable in a similar way.