Trying to have it both ways
Even though you are both creatures, and it should take two spells, or it should take another spell level on this one (cast as third level) to make you both invisible, let's suppose that your DM rules that the one invisibility spell covers you both (or see the special case below). Your friend the mage could have cast the spell on an elephant, and that's bigger than you both, right?
Since you both gain the benefit of that single invisibility spell, you (the combined "you" of mount and rider) should then gain all of the features of the spell, to include losing it with an attack. You have posited that you are "carried" by the mount, and you stay on it, which makes your attack directly associated with the mount and your joint invisibility -- so you both turn visible when you attack.
If you find a DM who rules other than what I just outlined, then exploit away, but I'll offer that p. 195 of the PHB rules against that exploit.
If you are hidden—both unseen and unheard—when you make an attack, you
give away your location when the attack hits or misses.
That's part of a larger paragraph on 'Unseen Attackers and Targets' on PHB p. 194-195.
Why I answered this way: the special case of Paladin/find steed
If you are a paladin, on your steed from find steed (PHB p. 240), and you have a Ring of Spell Storing with one charge of invisibility at 2nd level ...
"you can make any spell you cast that targets only you also target your steed."
Using that feature - without any exploit - the situation you described could arise of both mount and rider being invisible from one 2nd-level casting of the spell. But once an attack is launched, there goes the invisibility. (per p. 195 PHB, cited above).