It doesn't HAVE to be mod 12. This is just one example.
Mod 12 gives the remainder after dividing out all the 12s. So, 38(mod 12) == 38 - 12 == 26 == 26 - 12 == 14 == 14 - 12 == 2.
We can re-express 38 == 14 (mod12) as
38 = 14 + 12k for some integer k. Here, k = 2. We can also say
38 = 2 + 12m for some integer m. Here, m = 3.
We CANNOT say 38 == 19 (mod 12) because that would mean...
38 = 19 + 12n for some integer n. So,
19 = 12n,
19/12 = n, but this is not an integer. So, 38 is not congruent to 19 (mod 12).
Modular arithmetic is useful for division problems. For example, suppose you wanted to make a division rule for 5. We already know a number is divisible by 5 if its last digit is either 0 or 5. Let's prove it.
Suppose n = d0 + 10d1 + 100d2 + 1000d3 + ... + 10^k dk.
For example, if n = 593, then d0 = 3, d1 = 9, d2 = 5.
Now, n (mod 5) == d0 + 10d1 + 100d2 + ... + (10^k)dk
Notice that 10d1, 100d2, ... are all divisible by 5 since they are multiples of 10 (and 10 is divisible 5). Thus, they all == 0 (mod 5).
Therefore, n == d0 (mod 5).
If n == 0 (mod 5), then n is divisible by 5, and thus d0 is divisible by 5 since n == d0 (mod 5). The only digits divisible by 5 are 0 and 5. Thus, n is divisible by 5 if and only if d0 (the last digit) is 0 or 5.