What this GIF (animation) shows is how the squares from the two smaller sides combine together to equal the square of the large side. This is where the idea behind Pythagoras' theorem comes from.
What this is means the two shorter sided squares combined together add to make the larger square.
So there are some situations where the two sides need to be added, and others where the smaller side needs to be subtracted by the larger one.
To decide start by labelling the hypotenuse.
If the length of the hypotenuse is not known, add the sides.
If the length of the hypotenuse is know, subtract the smaller side from the larger.