Every year, several of my 17-year-old calculus students always ask how they could have come up with this trick – that is, multiplying by ${\frac{\cos x}{\cos x}}$ to get $$\int \frac1{\cos x} \, \mathrm dx = \int \frac{\cos x}{\cos^2 x} \, \mathrm dx =\int \frac{\mathrm d(\sin x)}{1 - \sin^2 x}$$ (from this answer).
How can I demystify "the way I used to integrate $\frac{1}{\cos x}$ is to multiply with $\frac{\cos x}{\cos x}$" (from this answer)?
If one were developing the theory from scratch, how would one find this solution (other than blind luck)?" I seek "good explanations and motivations for everything (as opposed to just pulling out ready-made solutions like what was done to me when I was learning this exact thing)." (Taken from this question.)
I'm NOT asking about other methods like integrating any function of the form $\sin^n(x)\cos^m(x)$ (like this), the tangent half-angle substitution, or multiplying by ${\sec x} \dfrac{\sec x+ \tan x}{\sec x+ \tan x}$ (like this).