This is not a coincidence. In fact, this is a fact that is true for any right angled triangle. This fact is expressed as the Pythagoras Theorem after the name of the Greek mathematician Pythagoras.
The Pythagoras Theorem states that
“In any right-angled triangle, the sum of the squares of the two smaller sides of the triangle equals the sum of the square of the hypotenuse”