Let $n > 1$, and let $d < n$ be a positive divisor of $n$. You want to count the number of elements of the set $$ A = \\{ a : 0 \le a < n, \gcd(a, n) = d \\}. $$ Note that if $a \in A$, then $\gcd\left(\dfrac{a}{d}, \dfrac{n}{d}\right) = 1$, so $\dfrac{a}{d} \in B$, where $$ B = \left\\{ b : 0 \le b < \frac{n}{d}, \gcd\left(b, \frac{n}{d}\right) = 1 \right\\}, $$ and $B$ has $\varphi(n/d)$ elements. Conversely, if $b \in B$, then $b d \in A$, as $$ \gcd(b d, n) = \gcd \left(b d, \frac{n}{d} d \right) = \gcd \left( b, \frac{n}{d} \right) d = d. $$
So $A$ has $\varphi(n/d)$ elements.