Why is the gender in the story mixed up?

#1

Im reading it for the first time and im happy with the story and keep reading. First I thought I just keep reading it false but now im certain. The princess is sometimes a man… him, his are mistaken. And the evil king is sometimes a girl. She and her are mistaken.
Is it just me misunderstanding it or not?