I think the first bug happens if I have previously logged out in the middle of a battle, when the opposite poke has fainted mine, before the hp bar decreases completely. I don't know if my explanation is clear enough, but I've just reencountered the bug and I think it was due to what I described above. I logged out after the opposite poke made the final hit but before the hp goes to zero. Next battle after this, my poke fainted as soon as the battle started.