You'll notice that this matches expression pattern a_ to Plus[1,x] and b_ to Plus[2, Power[y, 2]]. Then it returns the two, but squared (the a^2, b^2 part).

Another way to do this would be, as @Jens' link points out, using Apply, which passes the sequence of arguments from one function to another (i.e., g @@ f[a, b] becomes g[a, b] - note @@ is shorthand for Apply.

We use this to our advantage with the pure function which squares both sides of the expression.

Mathematica is a registered trademark of Wolfram Research, Inc. While the mark is used herein with the limited permission of Wolfram Research, Stack Exchange and this site disclaim all affiliation therewith.