Don't healing items always go first, before the attack?
Ok here is what I think happnened.
At a certain point of health, the NPC'c will heal their Pokemon.
Lets say that response is at 15HP>. If they survive at a higher HP, then they attack, if you hit them at the correct 15>, then the game will make them heal their Pokemon.
He went first the next turn... eg. Accelgor VS Carracosta, Accelgor attacks, Carracosta attacks, Accelgor heals
Your game is glitched...