PLEASE HELP!

I get the distance formula entirely, but there is just one thing i just don't get AT. ALL.

If I was given points A(3,10) and B(-2,-2), I have to do AB=square root (-2-3)^2+(-2+10)^2 and get 13.

But if I did it the other way around, AB=square root (3-(-2))^2+(10-(-2)^2, I get square root 65.

However, if I do this problem, C(0,8) D(-8,3), either way I do it, I get the right answer! Why? I thought it didn't matter however way you do it...why some problems, you get different answers and on others, you get the exact same answer?