A key for a permutation cipher is of course a permutation $\sigma \in S_n$.
It is self-inverse iff $\sigma^2 = e$, where $e$ is the identity permutation.
We can write any $\sigma \in S_n$ as a product of disjoint cycles in an essentially unique way (up to order of the cycles and leaving out or adding 1-cycles like $(x)$), and so we need all cycles of $\sigma$ to be self-inverse as well. So we can only use $2$-cycles and $1$-cycles. Of course $e$ itself (all $1$-cycles) is one solution. Then we have the cycle structure $2,1,1 $ of which we have $\binom{4}{2} = 6$ (we pick the two points in the $2$-cycle in an unordered way from the $4$ points. And finally we have cycle structure $2,2$, of which there are $\frac{4!}{2! 2! 2!} = \frac{24}{8} = 3$ (or by hand $(13)(24), (12)(34),(14)(23)$).
So we have $1 + 6 + 3 = 10$ many self-inverse keys.
How many involutions do we have for $n=5$? The cycle structure (we only have cycles of length 2 or 1 as in he tlinked answer) can only be $2,1,1,1$ or $2,2,1$. The former has $\binom{5}{2}=10$ realisations (just pick an unordered pair from $\{1,2,3,4,5\}$). The other has $5$ ways to pick the fixed point and then pick the unique point among $3$ remaining that will be in a cycle with the minimum of the remaining points. (say: we pick $2$ as fixed then $1$ is the minimal remaining point, and we pick one element from $\{3,4,5\}$ say $5$ to be in a cycle with it. The last 2 are the final cycle, so we get $(1)(25)(34)$ as a realisation, etc.)
So in all we have $10 + 5 \times 3 = 25$ involutions, plus $1$ if we count the identity too, (a bit of a silly "cipher"). I'm only counting exact order $2$ with $25$.
For $n=6$ we can have $2,2,2$ as well, etc. etc. Try it.
For the complete sequence see the online encyclopedia of integer sequences
The easiest way to compute it in practice, I think, is using the recursion $$i_n = i_{n-1} + (n-1)i_{n-2}, i_1 = 1, i_2 = 2$$ where $i_n$ is the number of involutions on $\{1,\ldots,n\}$: the first term is for the involutions that fix $n$, for the other term we pick one $j < n$ such that $(j n)$ form a cycle and consider involutions on the remaining $n-2$ points.
Best Answer
Thinking out loud: suppose $E(x) = ax + b \pmod{n}$ and that $E(E(x)) = x \pmod{n}$ for all $x$, so that
$$x = E(ax+b) = a(ax+b) + b = a^2x + (a+1)b \pmod {n}$$
Taking $x=0$ gives $(a+1)b = 0 \pmod n$ or $n | (a+1)b$. Then we are left with $x = a^2x$ for all $x$, so taking $x=1$ we indeed get $a^2 = 1 \pmod{n}$. The latter has $4$ solutions (for a proof see here e.g.), namely $a=-1$, $a=1$, the unique solution $s$ (modulo $n$) to $y=-1 \pmod{p},y=1 \pmod{q}$ and the unique solution $t$ (modulo $n$) to $y=1\pmod{p},y=-1 \pmod{q}$. (the Chinese remainder theorem guarantees their existence and uniqueness).
$a=-1$ always has $(a+1)b = 0 \pmod{n}$, for any $b$ (so $n$ of them) (this corresponds to all encryption functions of the form $E(x) = -x+b \pmod{n}$)
For $a=1$ we get $2b = 0 \pmod{n}$, this can only happen if $b=0$ as $n$ is odd. This thus gives $1$ solution: $E(x) = x$. (Not a very strong encryption :) )
For $a=s$ with $s+1 = 0\pmod{p}$ and $s-1 = 0 \pmod{q}$ we only have $pq| (a+1)b$ iff $q | b$. So we get all multiples of $q$ below $n$ ,of which there are $p$ ($b=0\cdot q,1 \cdot q, \ldots, (p-1)\cdot q$).
For $a=t$ we similarly get solutions for those $b$ that are multiples of $p$ below $n$ ($q$ many).
In all, I get $n +1 + p +q$ keys from these $4$ cases.