Alright, so I did this test at school, and I was asked to prove this identity:

So I went along my merry way:

and prepared to make it into

But being the clueless person I am, I included the intermediary step

which is wrong and loses marks even if it still reaches the answer.

The correct step in the given solution was to make a common denominator through:

And the thing is, I don't understand what the difference between the two methods is. As far as I can see, the given correct solution multiplies both sides of the fraction by

and I'm doing the same thing except multiplying by each cos(A) cos(B) one at a time instead of both at the same time. And as far as I can see, multiplying by two given numbers m and n is the same as multiplying by mn, right?

Yes that's correct.
I asked my teacher about this and she said something about not accounting for cos(A) = 0. She justified the given correct solution with something like "the existence of tan(A) in the original solution automatically rules out cos(A) = 0 and that's why we can multiply both sides of it, but you made it into an addition and needed an extra condition 'for cos(A) = 0' in that line" (I don't remember exactly)

The proof concludes:

Could someone shed some light on this? Thanks.