When I was younger I always thought the opponent's Pokemon beat you up causing this, but I know that it's not true now. Just wondering why?
When all your Pokemon faint you started to panic, adrenalin went through you and your protective instincts took you too the nearest Pokemon centre. You didn't actually black out. It just went so fast that it felt like you just blacked out.
But still, after seeing Gamefreak logic you probably got punched in the face by a water demon and flew to a Pokemon centre on a flying bathtub