It only happens when your opponent brings you to 0 hp and you survive while you shouldn't, not when you bring your opponent to 0.
It occurs when you should have been killed by Catapult, Unstable Gas and possibly some Spells, too. Doesn't always happen though.