To expand on that a little:
- In melee only one character can grab the ledge at a given moment. While doing a neutral getup / rolling onto the stage / ledge attacking your character is still considered to be occupying the ledge until the animation is finished. You also get about half a second of invincibility when grabbing the ledge. So if your opponents up-b hitboxes don't hit you, because your hurtbox is already busy rolling onto the stage or you just grabbed the ledge before they appear there, they can't grab it.
- Many recoveries in this game are very laggy when landing onto the stage (when you grab the ledge you basically get to skip the end lag). So making them recover onto the stage can lead to a big punish.