There is a small typo: $d_1(n) $ is the number of divisors congruent to 1 $\pmod{4}$, and similarly for $d_3(n) $.
Let's open the geometric series:
$$ \sum_n \sum_k q^n (-1) ^k q^{2nk} = \sum_{n, k} q^{n(2k+1) } (-1) ^k$$
Now we should group the terms depending on the exponent of $q$. For a given $m$ , which $n, k$ are such that $n(2k+1) =m$ ?
This happens exactly when we have an odd divisor $d=2k+1$ of $m$. The number $n$ will be then determined by $n= m/d$. Now we group the summands depending on the exponent of $q$ as we promised, then we use the substitution $d=2k+1$ :
$$ \sum_m \sum_{n(2k+1)= m } q^{m} (-1) ^k = \sum_m q^m \sum_{d \mid m \text{ odd}} (-1) ^{\frac{d-1}{2}}$$
Let's further separate the odd divisors in two classes. If $d\equiv 1 \pmod{4}$, then the quantity $(d-1) /2$ is even and the sign appearing is $+1$. If $d\equiv 3 \pmod{4}$, then the sign appearing is $-1$. On balance we will have
$$\sum_{ d \mid m \text{ odd}} (-1) ^{\frac{d-1}{2}} = \sum_{ d \mid m \ \ d \equiv 1 } (+1) + \sum_{ d \mid m \ \ d \equiv 3 } (-1) = d_1(m) -d_3(m) $$
Plugging this into the original equation we get
$$\sum_m q^m \sum_{d \mid m \text{ odd}} (-1) ^{\frac{d-1}{2}} = \sum_m (d_1(m) -d_3(m)) q^m$$
As desired.