Proving the Möbius Inversion theorem. Given $g(m)=\sum_{d\mid m}f(d)$, and the identities $$\sum_{m\mid n}a_m = \sum_{m\mid n}a_{n/m}$$  $$\sum_{m\mid n}\sum_{k\mid m} a_{k,m}=\sum_{k\mid n}\sum_{l\mid (n/k)} a_{k,kl}$$ $$\sum_{d\mid m}\mu(d)=[m=1].$$
The Möbius Inversion Theorem ($f(m)=\sum_{d\mid m} \mu(d)g(\frac{m}{d})$) can be proved by using these identities:
$$
\begin{align}
\sum_{d\mid m}\mu(d)g\left(\frac{m}{d}\right) & =\sum_{d\mid m}\mu\left(\frac{m}{d}\right)g(d) \tag{by the first identity} \\[6pt]
& =\sum_{d\mid m}\mu\left(\frac{m}{d}\right)\sum_{k\mid d}f(k) \tag{by the definition of $g$} \\[6pt]
& =\sum_{k\mid m}\sum_{d\mid (m/k)}\mu\left(\frac{m}{kd}\right)f(k) \\[6pt]
& =\sum_{k\mid m}\sum_{d\mid (m/k)}\mu(d)f(k) \\[6pt]
& =\sum_{k\mid m}\left[\frac{m}{k}=1\right]f(k)=f(m)
\end{align}
$$
However, I do not understand the third step, where $\sum_{d\mid m}\mu(\frac{m}{d})\sum_{k\mid d}f(k)$ is reduced to $\sum_{k\mid m}\sum_{d\mid (m/k)}\mu(\frac{m}{kd})f(k)$, I'm pretty sure it is to do with the second identity.
Here, $m\mid n$ denotes $n$ is divisible by $m$ ($n=mk$ for some integer k) and $$[P]=\begin{cases} 1 &\text{if $P$ is true}\\ 0 &\text{if $P$ is false}\end{cases}$$
 A: They've flipped the order of summation. This is extremely common in number theory, so let's look at it closer:
$$\sum_{d\mid m}\mu(\frac{m}{d})\sum_{k\mid d}f(k) = \sum_{k\mid m}\sum_{d\mid (m/k)}\mu(\frac{m}{kd})f(k)$$
The first expression is the same as $\displaystyle \sum_{d \mid m}\sum_{k \mid d} \mu(m/d)f(k)$, where all we have done is collect the two sums together. What does it mean that $d \mid m$? It means that $m = de$ for some $e$. What does it mean that $k \mid d$? It means that $d = kl$ for some $l$. Putting these together, this means that $m = elk$. In this notation, $m/d = m/lk = e$. Then our sum is the same as summing over the possible factorizations of $m$ into three parts $efk$: $\displaystyle \sum_{m = elk} \mu(e)f(k)$.
Let's think of summing over the $k \mid m$ first. By this I mean that we can view our sum as $\displaystyle \sum_{k \mid m} \sum_{el = m/k}f(k)\mu(e)$. But then $e = \frac{m}{lk}$, ranging over the $l$ that divide $\frac mk$. So we can rewrite this last sum as $\displaystyle \sum_{k \mid m} \sum_{l \mid (m/k)}f(k)\mu(\frac{m}{lk})$, which is exactly what we wanted to show.
