
The formula is derived from the (a+b)² which can be expanded as:

Now since we only want a²+b² and not 2ab. We can add -2ab after (a+b)² which result in (a+b)²-2ab. This formula is pretty useful it comes to higher maths.
Answer
If this is not what you are looking for then let me know through comment!