I think it's more consistent to say when you're seen or you attack, you're no longer hidden, applying that same requirement across the board.
But the rule already does say that when you attack you are no longer hidden. If you do it from a position of hiding, you reveal yourself after the attack is made.
You're also (in many cases) still hidden when you launch the attack.
Example:
Scenario: You're walking home from a visit to your FLGS mid-afternoon; Volos Guide to Monsters safely in hand. I'm lying in wait for you on a rooftop 60' away, watching you walk down the street over the sights of a paintball gun (hidden).
Lets assume I rolled a 15 for my Stealth check. As long as your passive perception is 15 or less, you wont see me up there and I am hidden from you. If your passive perception is higher than 15, you'll notice my silhouette on the rooftop, catch a glimpse of the reflection of the guns scope, hear me let out a cough, or otherwise notice me somehow.
If you notice me, I'm not hidden (and as we are now aware of each other, combat starts and initiative is rolled). In this case, If I win initiative and go first on round 1, I can still shoot you, but don't have advantage on the check (I'm not hidden). If you go first, you get to bolt to cover [use your movement to move 30' and then use the dash action to move another 30'] and yell at me to stop acting like a jerk and put the paintball gun down.
If you don't notice me up there with my sights trained on you, I get to shoot you with my paintball gun. Lets assume I decide to do so, and pull the trigger' thus starting the combat sequence. We both roll initiative, and (as you are unaware of me) you are surprised and don't get to act on turn 1.
Lets assume you roll higher on initiative (I'm a clutz in real life, so my Dex isnt the highest). You suddenly get the sense that something is very wrong, as you hear a strange popping sound coming from a roof 60' away and hear some loud laughing in what sounds like an Australian accent. Unfortunately as you are
surprised, you cant act or move on your turn one. Your turn ends with you having a sinking feeling, but unable to do anything about it. From now on you can take reactions.
My turn 1 comes about. I now get to resolve my action. As I was hidden when I made my attack, I get to make my attack roll with advantage. The range on my paintball gun is 70' so we're all good there (no disadvantage for range to cancel out the advantage for being hidden). I'm proficient in the paintball gun, but my Dex isn't great. Lets assume (thanks to advantage) I just manage to scrape in a hit. It does no damage, but does leave a bright orange stain on your new shirt.
Now, (as soon as the attack is resolved) I am no longer hidden. Your brain finally starts to process what is going on, and between the sound of the shot, the laughter as I reveal myself, the trajectory of the stinging paintball and your sudden sense of 'damn what the heck!' shaking you into hyper-awareness, you see a grinning 40 year old Aussie guy on a rooftop, holding a paintball gun, and running away at high speed (I used my movement after the attack, to flee along the rooftops!).
Round 1 ends, Round 2 begins, and its now your turn.
See how it all comes together?