Its explained via modular arithmetic which is a standard tool and area of research in number theory.
Generically if x = Np + q where N and p are integers then it is said that x = q mod p, ie x is q more than a multiple of p. For example 7 = 2 mod 5, since 7 = 5*1 + 2, 23 = 7 mod 16 or 23 = 7 mod 8. It easily explains things like why a number which is divisible by 3 also have the sum of its digits divisible by 3.
We use base 10, which is 1 more than a multiple of 3, ie 10 = 1 mod 3. Now consider a number with 2 digits (ie its between 10 and 99 inclusive), which we'll write as XY (for example if we consider 56 then X = 5, Y = 6 or for 93 X = 9 and Y = 3 etc). It follows that XY = 10*X + Y, so for 56 we have 56 = 5*10 = 6 etc. Now consider this in mod 3, where we have 10 = 1 mod 3. Thus we have XY = X*10 + Y = X*(3*3+1) + Y and taking this mod 3 gives XY = X*1 + Y mod 3 = X+Y mod 3. Thus the 2 digit number XY is divisible by 3 if X+Y is. This works for any number of digits because $$10^{N} = 1$$ mod 3 for all whole numbers N.
For instance, consider 5541. Is this divisible by 3? Well 5541 = 5+5+4+1 mod 3 = 15 mod 3. So 5541 is divisible by 3 if 15 is. Obviously it is but we can use the same method again to see it, ie 15 = 1+5 mod 3 = 6 mod 3 and 6 is divisible by 3, so 15 is, so 5541 is. Its clear that you can do this for any sized initial number, repeating it again and again until you get a single digit number which you can easily determine whether its a multiple of 3.
For instance, is 536392004240671 divisible by 3? We add up the digits, 5+3+6+3+9+2+0+0+4+2+4+0+6+7+1 = 52. Now add its digits up, 5+2 = 7. 7 isn't divisible by 3 and thus neither is 536392004240671. Didn't even need a calculator!
Precisely the same applies to mod 9 arithmetic. If you use hexidecimal (base 16) then it works for mod 5, mod 3 and mod 15. If you use base 12 then it works for mod 11 arithmetic.