Instead of multiplying the top and bottom of the 2nd term by cos^2 A, you can instead DIVIDE the top and bottom of the FIRST term by cos^2 A.
After replacing the resulting sec^2 A by (1+tan^2 A), you get another perfect square in the numerator which cancels as before.
This avoids magically...