There are many counterexamples given in the comments, but here is the thought process for coming up with such a counterexample, as well as the most general form of these counterexamples:
We are interested in finding a set $E$ and a function $f:E\to E$ such that
$$ f^{-1}=f\neq Id_E$$
Note that $f=f^{-1}$ means that if we take some $x\in E$, then apply $f$ to it twice, we need to get back $x$. So if we choose some other element $y\in E$ arbitrarily, and define $f(x)=y$, then we are forced to also define $f(y)=x$. So we can imagine constructing the function $f$ one element at a time, by choosing a random output for that element, and then also defining $f$ on that random output to be the element we started with.
If we have a finite set $E$, we can just exhaust it by defining $f$ on one element at a time (if there were an odd number of elements, choose one to send to itself), but if we are interested in examples with infinite sets, this won't work anymore, instead we can notice that what was really happening in the finite case was that we were pairing elements with one another, so inspired by this in the infinite case, if we are able to partition $E$ into two parts, $A,B\subseteq E$ such that the following holds:
$$ A\cup B = E,\ A\cap B=\emptyset$$
And
$$A\simeq B$$
Then since $A\simeq B$ there is some bijection
$$h:A\to B$$
Which is exactly the kind of "pairing" we needed, so now we can define
$$f= \begin{cases} h(x) & \mbox{ if } x\in A\\
h^{-1}(x) &\mbox{ if } x\in B
\end{cases} $$
Which satisfies $f=f^{-1}$. So a function with this property is essentially one which arises from a partitioning of $E$ into two bijective parts.
Note: this is not quite the most general form, you could have a third segment $C$ such that $E=A\cup B\cup C$, with all the other restrictions in place, and then define $f$ so that $f|_{C}=Id_C$, but this I find less interesting