This is not a Math issue, it is a matter of how a condfitonal test is carried out. Conditions are tested as pairs (with a left to right hierarchy unless otherwise arranged using parentheses), meaning for 2 == 2 == whatever, first the test is performed to see if 2 == 2 ?, which is true, meaning the result evaluates as a "true". Then the next comparison is performed using the result of the first... which would be... true == whatever ?. which depends on "whatever" is. A 1 evaluates as true as far as logic goes, but any other number does not, so true == 1 = true, true == 0,2,3,4,5.... = false
You will find nothing passes the test if you reverse the order of the numbers.
If you want to do compound conditional tests you are best to do it in pairs and/or use parentheses to define the order in which evaluations are managed.