you're right, that multiplying by (secx + tanx)/(secx + tanx) looks pretty arbitrary, but it's just the common short-cut that is shown.
Another way to do this integral yourself is to rewrite it like this:
secx
= 1/cosx
= cosx/cos²x
= cosx/(1-sin²x)
On that last line, let something like z=sinx, and then use partial fractions.