Why do Alice and Bob get the same key even after modular reduction in Diffie-Hellman Cryptography?
In general, we have that $a\cdot b \mod n = (a\mod n) \cdot (b\mod n) \mod n$ for any positive integers $a,b,n$. To see this, we write $a= k n +r_a$ and $b=ln+r_b$, where $r_a= a \mod n$ and $r_b = b\mod n$. 
So, we get 
\begin{align}
a\cdot b \mod n &amp;= (kn +r_a) (ln+r_b) \mod n \\
&amp;= kln^2 +knr_b + ln r_a + r_ar_b \mod n\\
&amp;= n (kln +kr_b + lr_a) + r_ar_b \mod n\\
&amp;= r_ar_b \mod n\\
&amp;= (a\mod n) \cdot (b\mod n) \mod n
\end{align}

From this, it follows that $a^b \mod n = (a\mod n)^b \mod n$ for any positive $a,b,n$. Using this equality, we can 'move' exponents through modular reductions, from which your equality follows.