If $f:\mathbb R\to\mathbb R,f(x)=x|x|$ and $g: \mathbb R\to \mathbb R, g(x)=-x|x|$ then all three roots of $f(x)=f^{-1}(x)$ and $g(x)=g^{-1}(x)$ lie on $y=x$ and $y=-x$, respectively.
It will be interesting to have concrete example(s) of $h: A \to B$ where all roots of $ h(x)=h^{-1}(x)$ do not lie on $y= x$ or $y=-x$. Can you suggest one?
Edit Please do not consider the case(s) of no real rootroot and self inverse functions.

For sets $A=B=\mathbb R\setminus\{0,1\}$, $h:A\to B$,
$$h(x)= \begin{cases} \frac 1x & x>0 \land x\ne 1\\ 2x & x< 0 \end{cases},$$
some and all roots of $h(x)=h^{-1}(x)$ do not lie on $y=x$ or $y=-x$.
$h$ is not a self-inverse function.