So did Bran basically plan all this from the start?
The running theme throughout the final season was the distinctive lack of continuity. Things that happened in previous episodes had very little bearing on the following episode/s.
The Red Keep falls on Jaime and Cersei in the previous episode, and in the final we discover it was just a couple of well-placed bricks that hit them. If they'd moved 5 steps to the left they'd have been fine. Arya rides away from the direction of the Red Keep in the previous episode, but then this episode begins there, with her there. Where was she riding to? From a writing viewpoint, what was the point of the horse? The season is full of continuity blunders large and small. The end of the Dothraki, nope here they are. The power of the scorpions, gone. Jaime decides to stay north, nope going south.
While the writing dual of D&D were able to take the novels and create a script out of it, doing something 'original' those two failed badly.
There is a petition to get season 8 remade with competent writes;
Number of faces worn by Arya? Zero.
Number of political schemes enacted by Sansa: maaaybe one if "telling Tyrion the truth" counts as a scheme.
Number of useful things Bran learned with his visions: maaaybe one, if "the Night King wants to kill me, not that he doesn't want to kill everyone else too" counts as useful.
Well, he survived because no one saw him kill Dany, so no one knew he did! I mean, it's not like her body was there, and only Drogon saw him enter.
.... so, wait, how did he get arrested?
He must have told Grey Worm! All guilty and stuff.
.... so, why didn't Grey Worm kill him?
.... because no one knew he did it! I mean ....
Eh, something something MAGIC!
You seem to forget one of GRRM's stated purposes in writing the series - to teach genre fans lessons about how things don't work out the way they want them, to specifically defy your narrative expectations.