The way surprise works in 5e is the following:
- When you attack someone who didn't expect you to (for example, because he didn't know you where there), that creature is surprised. This means that you roll initiative as normal, but the surprised creature is more or less "tagged" as surprised, which allows for example assassin rogue (not all rogues!) to get automatic crits - also, a surprised creature can't take reactions. Once they reach their initiative, they remove this tag, but can't do anything else during this turn. They can, however, now take reactions (such as opportunity attacks).
- Getting advantage: You basically get advantage on the attack when the attacked creature didn't know you were there / didn't see you. So, if you lay an ambush and jump a group of goblins, they are surprised and you have advantage. If you are talking with someone and suddenly decide to stab them, though, you do NOT have advantage, even though the attacked creature might be surprised (depending on whether it expected you to attack it).
Note that not every enemy in a group has to be surprised, and neither do all your players have to be hidden to get advantage.
For example, if you attack an mage and some orcs, and the mage spots you but the orcs don't, then the orcs are surprised but the mage is not.
Similiar, if you are for example a heavily armored cleric with a terrible stealth roll who got spotted by both the orcs and the mage, your super-sneaky rogue might still be unseen and get advantage.
However, if an enemy is aware of any enemy, he can't be surprised. So, if the mage spots your cleric, but not your (assassin) rogue, the rogue will not get his auto-crit, since the mage is not surprised. He will still get advantage from being unseen, though. (Note that you reveal your location when making an attack, whether that hits or misses)