For me, the only way I can remember this sort of complicated identities is through the relationship between the
complete elliptic integral of the first kind
$K(k)$ and the corresponding arithmetic-geometric mean.
$$K(k) = \int_0^\frac{\pi}{2} \frac{d\theta}{\sqrt{1-k^2\sin^2\theta}} = \frac{\pi}{2\text{AGM}( 1, \sqrt{1-k^2})}\tag{*1}$$
Consider following integral
$$I(a,b) = \int_0^{\frac{\pi}{2}}
\frac{d\theta}{\sqrt{a^2\cos^2\theta + b^2\sin^2\theta}}$$
Introduce $x = b\tan\theta$, we can rewrite it as
$$I(a,b) = \int_0^{\frac{\pi}{2}} \frac{d\tan\theta}{
\sqrt{(1+\tan^2\theta)(a^2+b^2\tan^2\theta})}
= \int_0^\infty \frac{dx}{\sqrt{(x^2 + a^2)(x^2+b^2)}}\tag{*2}$$
Substitute $x$ by $\sqrt{ab} t$, we have
$$I(a,b)
= \frac{1}{\sqrt{ab}}\int_0^\infty \frac{dt}{\sqrt{t^4 + \left(\frac{a}{b}+\frac{b}{a}\right)t^2 + 1}}
= \frac{1}{\sqrt{ab}}\int_0^\infty \frac{1}{\sqrt{ ( t - t^{-1})^2 + \frac{(a+b)^2}{ab}}}\frac{dt}{t}
$$
Notice the last integrand is invariant under transform $\displaystyle\;t \leftrightarrow \frac{1}{t}$. If we introduce two more variables $s$ and $y$ such that
$$s = \frac12 (t - t^{-1}) = \frac{y}{\sqrt{ab}}$$ and using the fact $$\frac{dt}{t} = \frac{d(t - t^{-1})}{t + t^{-1}} = \frac{ds}{\sqrt{s^2+1}}$$
We can rewrite $I(a,b)$ as
$$
\frac{2}{\sqrt{ab}}\int_1^\infty \frac{1}{\sqrt{ ( t - t^{-1})^2 + \frac{(a+b)^2}{ab}}}\frac{dt}{t}
= \frac{2}{\sqrt{ab}}\int_0^\infty
\frac{ds}{\sqrt{\left(4s^2 + \frac{(a+b)^2}{ab}\right)(s^2+1)}}\\
= \int_0^\infty
\frac{dy}{\sqrt{\left(y^2 + \left(\frac{a+b}{2}\right)^2\right)(y^2 + ab)}}
$$
Compare this with $(*2)$, we obtain an important identity:
$$I(a,b) = I\left(\frac{a+b}{2}, \sqrt{ab}\right)$$
This means $I(a,b)$ is invariant if we replace $(a,b)$ by their AM and GM.
Start with any pair of numbers $a,b$, it is well known if you repeat taking AM/GM of them,
the pairs will ultimately converge to a single number. This is called the arithmetic geometric mean of $a$ and $b$ and usually denoted as $\text{AGM}(a,b)$. If one replace $a$, $b$ by this AGM in the definition of $I(a,b)$, we obtain
$$I(a,b) = \frac{\pi}{2\text{AGM}(a,b)}$$
Together with the obvious identity $K(k) = I(1,\sqrt{1-k^2})$, we immediately obtain $(*1)$.
Using these tools and notice $\text{AGM}(a,b)$ is homogenous. i.e.
$$\text{AGM}(\lambda a, \lambda b) = \lambda \text{AGM}(a,b) \quad\implies\quad I(\lambda a, \lambda b) = \frac{1}{\lambda} I(a,b),$$
the desired identity follows immediately.
$$
K(k)
= I(1,\tilde{k}) = I\left(\frac{1+\tilde{k}}{2},\sqrt{\tilde{k}}\right) = \frac{2}{1+\tilde{k}} I\left(1,2\frac{\sqrt{\tilde{k}}}{1+\tilde{k}}\right)\\
= \frac{2}{1+\tilde{k}} K\left( \sqrt{1 - \frac{4\tilde{k}}{(1+\tilde{k})^2}} \right)
= \frac{2}{1+\tilde{k}} K\left( \frac{1-\tilde{k}}{1+\tilde{k}} \right)
$$