Let’s just… not try to apply logic to that episode.
I guess… Remember that the TARDIS is a sentient being, who on occasion does things because she decides she wants to. She’s also telepathic. So it may not be so much that Clara flew it that she basically sort of suggested, and the TARDIS went ‘yeah alright’.
How did they get to Gallifrey? Beats me. No fucking clue. The Time War and Time Lock are nuWho inventions. SUPPOSEDLY they shouldn’t be able to, certainly not by accident.
And I mean not only that, but flying into Gallifrey’s past is maybe impossible, more probably just highly illegal. Like that’s the reason time passes linearly on Gallifrey, despite Time Lords bouncing all over history everywhere else.
They have a SHITTON of rules and restrictions on time travel, and on Gallifrey itself they are definitely in a position to enforce it. Theoretically you cannot land on Gallifrey (certainly not within the capitol, though the barn obviously wasn’t that) without authorisation? They made the time capsules, they know how to stop them, trap them, ground them…
So basically I find it HIGHLY strange they apparently managed to end up on Gallifrey.
Also that Thete was apparently sleeping in a barn. And was supposed to join the army in place of entering the academy?? Like.. that.. that is not how… That’s not how it’s ever been written, actually??? Thete is a fancy upper class kid, they probably didn’t have much choice in entering the academy whether they wanted to or not.
I JUST DON’T KNOW.