If $G$ be a group of order $8$ and $x$ be a element of order $4$. Prove that $x^2 \in Z(G)$
Hint:
Normality only implies that $gH=Hg$, i.e. $$gh_1 = h_2g$$ where $h_1,h_2\in H$ might be different. Since $x$ has order four, list all elements of $H$. If $gx^2 = hg$, what could $h$ be?
$gH=Hg$ does not imply that $gh=hg$ for all $h\in H$. These are different things.
Here is a possible solution. Let $g\in G$. Then $gx^2g^{-1}=(gxg^{-1})^2$. Since $\langle x\rangle\trianglelefteq G$ we know that $gxg^{-1}\in\langle x\rangle$. Now what $gxg^{-1}$ might be? Of course it can't be the identity $e$ because the identity is conjugate only to itself. Also it can't be $x^2$ because then we would get $e=(x^2)^2=(gxg^{-1})^2=gx^2g^{-1}$ which is again a contradiction. Hence $gxg^{-1}$ is either $x$ or $x^3$ and hence $gx^2g^{-1}=(gxg^{-1})^2=x^2$.
This can be obtained by several methods.
(1) There are only two non-abelian groups of order $8$: $D_8$ and $Q_8$. You can check them respectively.
(2) $Z(G)$ must have order $p$ if $G$ has order $p^3$, with $G/Z(G)\cong\mathbb{Z}_p\times\mathbb{Z}_p$. In this case $p = 2$ and so $G/Z(G)\cong\mathbb{Z}_2\times\mathbb{Z}_2$. Hence for any $gZ(G)\in G/Z(G)$, $g^2Z(G) = Z(G)$.
Therefore, a more general case is that if $G$ has order $p^3$, where $p$ is a prime number, then $g^p\in Z(G)$ for all $g\in G$ (not necessarily to be of order $p^2$). In your question, $x$ is not necessarily to be of order $4$.