Zagier has a very short proof ( MR1041893) for the fact that every prime number $p$ of the form $4k+1$ is the sum of two squares. The proof takes defines an involution of the set $S= \lbrace (x,y,z) \in N^3: x^2+4yz=p \rbrace $ which is easily seen to have exactly one fixed point. This shows that the involution that swaps $y$ and$ z$ has a fixed point too, implying the theorem.
This simple proof has always been quite mysterious to me. Looking at a precursor of this proof by Heath-Brown did not make it easier to see what, if anything, is going behind the scene. There are similar proofs for the representation of primes using some other quadratic forms, with much more involved involutions.
Now, my question is: is there any way to see where these involutions come from and to what extent they can be used to prove similar statements?

