A proof for the identity $\phi(n)=\sum_{d\mid n}\mu (d) \left(\frac{n}{d}\right)$ several times in this website. After studying the book Apostle's Analytic Number Theory and failed to understand I read through the answers in MSE also, but I can't understand them as well!
The book is clear enough except for the step that I put a question remark which the text isn't convincing about.
Normally when summation is over two variables the order of summation doesn't matter, but here exchange of sum over k and over d is not understandable!
How the following equality holds: $$\sum_{d|1} \mu (d) + \sum_{d|2 \ \text{and} \ d|n} \mu (d) + \dots +\sum_{d|(n-1) \ \text{and} \ d|n} \mu (d) + \sum_{d|n} \mu (d) = \sum_{d|n} \mu (d) \dfrac{n}{d}?$$
Note. $(n,k) = \gcd (n,k)$. & $[x]$ is the smallest integer less than or equal to $x$.
Simple clear explanations would be much appreciated.

we start from the definition : $$\varphi(n) = \sum_{k=1}^n 1_{ gcd(n,k)=1}$$
then a step requiring a proof : $$\sum_{k=1}^n \sum_{d |n, d| k} f(d) = \sum_{k=1}^n \sum_{d=1}^n f(d) 1_{d |n} 1_{d | k} = \sum_{d=1}^n \sum_{k=1}^n f(d) 1_{d |n} 1_{d | k} =\sum_{d=1}^n f(d) 1_{d |n} \sum_{k=1}^n 1_{d | k}$$
$$ = \sum_{d|n} f(d)\sum_{k=1, d | k}^n 1 =\sum_{d|n} f(d) \sum_{q=1}^{n/d} 1 = \sum_{d |n} f(d) \frac{n}{d}$$
finally, once we know that $\sum_{d | n} \mu(d) = 1_{n=1}$, we use $$ 1_{ gcd(n,k)=1} = \sum_{d \ |\ gcd(n,k)} \mu(d)$$ and we get
$$\varphi(n) = \sum_{k=1}^n 1_{ gcd(n,k)=1} = \sum_{k=1}^n \ \sum_{d \ |\ gcd(n,k)} \mu(d) = \sum_{k=1}^n \sum_{d |n, d| k} \mu(d) $$
$$ =\sum_{d |n} \mu(d) \frac{n}{d}$$