For $g \in G$, let $y_g$ be an element of $G$ such that $y_g g y_g^{-1} = g^{-1}$. For $g, h \in G$, let $x_{g,h} = gy_h^{-1}$.

Note that $ghg^{-1}h^{-1} = (gy_h^{-1}y_h)h(gy_h^{-1}y_h)^{-1}h^{-1} = xh^{-1}x^{-1}h^{-1}$ where $x = x_{g, h}$.

Then, $$ \displaystyle\sum_{g,h} ghg^{-1}h^{-1} = \displaystyle\sum_h \displaystyle\sum_g ghg^{-1}h^{-1} \\= \displaystyle\sum_h \displaystyle\sum_g (gy_h^{-1})h^{-1}(gy_h^{-1})^{-1}h^{-1} = \displaystyle\sum_h \displaystyle\sum_g gh^{-1}g^{-1}h^{-1} = \displaystyle\sum_{g, h}gh^{-1}g^{-1}h^{-1} $$

We also have $$\displaystyle\sum_{g,h} g^2h^2 = \displaystyle\sum_g \displaystyle\sum_h g^2h^2 \\ = \displaystyle\sum_g \displaystyle\sum_h g^2(g^{-1}h)^2 = \displaystyle\sum_g \displaystyle\sum_h ghg^{-1}h = \displaystyle\sum_{g, h} ghg^{-1}h = \displaystyle\sum_{g, h} gh^{-1}g^{-1}h^{-1}$$

For any $x \in G$, $(g, h) \mapsto (gy_h, y_h^{-1}g^{-1}h^{-1})$ is an explicit bijection from $\{(g, h) \in G \times G \mid ghg^{-1}h^{-1} = x\} $ to $\{(g, h)\in G \times G \mid g^{2}h^{2} = x\}$ with inverse $(g, h) \mapsto (gy_{h^{-1}g^{-1}}^{-1}, h^{-1}g^{-1})$.


I think you could also calculate those directly, using this Number of ways a group element of a finite group can be written as a given word and the hypothesis that every element is conjugate to it's inverse to get the result. It all comes about calculating that $\sum_{(g,h) \in G^2} \chi(g^2h^2) = \frac{|G|^2}{\chi(1)}$ for all irreducible characters $\chi$, from which the result would follow (the calculations for the commutator case are fairly simple and yield the number of ways to write $x$ to be $|G| \sum_{\chi} \frac{\chi(x)}{\chi(1)}$ where the sum is taken over all irreducible characters).