Take a two-digit base-10 number where the digits are represented by ab. This number is equal to 10a + b and the sum of its digits are a + b.
The difference between the number and the sum is 9a, which is divisible by three. So a + b is divisible by three, if and only if, 10a + b is divisible by three. 9a is also divisible by nine, meaning that the rule applies to nine as well as three.
With a three-digit base-10 number, the number is equal to 100a + 10b + c and the sum is a + b + c. The difference between the number and the sum are 99a + 9b, which is divisible by three and nine. Four-digit numbers, five-digit numbers, etc. work the same way.