I know the problem. Not a glitch though.
When two Pokemon faint, you will be asked to switch a new Pokemon in. Tap that Pokemon, and tap one of the fainted Pokemon. The Pokemon you selected will appear in the fainted Pokemon's place. Do the same for the second Pokemon.