The invisible one in my experience, happens when the defender uses a charge move that would cause your Pokemon to faint, but faints before it finishes using it, so on your screen it looks like both fainted.
The "regular" one where your Pokemon keeps switching out and back in happens when you correctly dodge but the undodged damage is enough to make your Pokemon faint.