RSA Algorithm modulo operation As per wikipedia
$$c = m^e \bmod n$$
where $c$ is the cipher text and $m$ is the original message.

To decrypt $$m = (c^d) \bmod n$$ that is $$m = (m^e \bmod n)^d \bmod n$$

My question is how do we have the following equivalence? $$(m^e \bmod n)^d \bmod n \equiv (m^e)^d \pmod n$$
The maths is fairly straightforward.

Replace $m^e$ with $a + bn$, where $a = m^e \bmod n$, and $b$ is an integer (equal to $\lfloor m^e / n \rfloor$).

The binomial expansion of $(m^e)^d$ can then be substituted with the expansion of $(a + bn)^d$ as follows:

$$(a + bn)^d = a^d + c_1a^{d-1}.bn + c_2a^{d-2}.b^2n^2 + \cdots + b^dn^d$$

where $c_1$, $c_2$ etc. are binomial coefficients.

Apart from the first term $a^d$, every term in this expansion is a multiple of $n$ and is therefore equal to zero (mod $n$).

Hence, $(m^e)^d \bmod n \equiv a^d \bmod n \equiv (m^e \bmod n)^d \bmod n$