She wanted to leave, even escaped at one point but the emperor wanted her back. Once she was found, he offered to adopt her but she refused. They compromised and she agreed to stay for a period of time ( i don't remember if it was a year or less) so she's staying till she settles things with Elencia
The other comme tu told you the event but not Philomel's motivation. Basically, because of the book, Philomel grew up convinced that she couldn't be loved because she wasn't the emperor's family. She took the book's content as the unavoidable truth. But after she's escapes, little by little she understand that there was more to it, first with the idea of family that she had made in her mind, then to her relationship with other people who loved her (at that point she's basically "confronting" the book), when she was unable to receive that love, and then because of Ellencia's weird behaviour.
She initially stayed cause the emperor didn’t want her to go. But then she said she will stay until she figured out what tf was going on with Ellensia. Then she said she won’t go until she’s dealt with the “invader”. But she’s still planning on leaving. She promised Leguin to go back to the tower with him, and secured lands and a company to live off of independently of the emperors money

if anyone who is caught up doesnt mind… could you share why philomel is still staying in the palace despite having a family outside and og fl harassing her at every opportunity