It's because Xerneas doesn't use a move or need some conditions to change its form, it's automatic, so when you change it's form prior to battle it will just automatically changes back to original afterwards. The main reason though I change it form prior to battle is so I could use another ability. When you change Xerneas ability, it will turn back to fairy aura the moment it gets out coz of the form change, so I changed its form prior to battle then give it a new ability, the new ability didn't change through out the battle coz it is already on active form but after the battle it still turned back to its original form making its ability back to fairy aura.. Basically stuck with it lol
I used an hex editor, I edited the Pokemon file(Pkx).