Proving equivalences of mod I need to prove that
$$(ab)\bmod m = \bigl((a \bmod m)(b \bmod m)\bigr)\bmod m,$$
but I don't know why the last "$\mathop{\bmod} m$" is there.
 A: One may say the last $\bmod m$ is there to insure that your $(a \bmod m)(b \bmod m)$ is in $\mathbb Z_m$ ($\mathbb Z_m$ being the set of non-negative integers less than $m$, $\Bbb Z_m = \{0, 1, 2, ..., m-1\}$.)
Alternatively, here's another way of saying exactly what you're trying to prove:
If $a\equiv i \pmod m$ and $b\equiv j \pmod m$, then $ab\equiv ij \pmod m$.
A: What "$\bmod\,m$" means here is "take the remainder when you divide by $m$". The reason the last one is there on the right hand side (RHS) is because $(a \bmod m)(b \bmod m)$ could still be larger than $m$. For example suppose $a=7,b=8,m=5$ then $(a \bmod m)(b \bmod m)=(2)(3)=6$ which is larger than $5$. On the LHS we would have $ab \bmod m=7*8 \bmod 5=56 \bmod 5=1$. So you can see that we need that last $\bmod\,m$ on the RHS to make the two sides equal.
By the way, people usually use "$\bmod\,m$" to mean something slightly different. They write it after an equation, like this:$$(m+3)^2\equiv 9 \pmod m$$
When people use "$\bmod\,m$" like this, it isn't applying to the right hand side of the equation. Instead it's applying to the whole equation. What it means is that the remainder we get when we divide the RHS by $m$ is the same as the remainder we get when we divide the LHS by $m$. People use a weird equals sign with three lines to remind themselves that this isn't true equality, but only equality $\bmod\,m$ (although sometimes people get sloppy and use $=$).
EDIT: Mathematicians normally use "$\bmod\,m$" applied to the whole equation. Programmers normally use it as an operator, like you're using it (sometimes they use the symbol '$\%$'). Programmers also distinguish between variants that give different results depending on the sign of the operands, one form more useful and intuitive and the other more efficient: see this SO question.
