According to the theory of a reddit user Bran uses his powers to go back in time in an attempt to eradicate the White Walkers, but ends up trapped in the Night King’s body. Here is how…
At some point we will arrive at the end of Game of thrones, and probably many deaths will take place. That’s when Brandon Stark, son of Eddard Stark, decides he’ll travel back in time and try to stop the Night king, his army, and the events from taking place. I will write about his journey back in time after explaining how it’s possible he can do this.
When the three-eyed raven says “You will never walk again, but you will fly” he means through time, and not only warging a dragon like many fans believe. There was a reason Jojen Reed (who also had the greensight and knew even more things about it than Bran) did not become the three-eyed raven himself. The reason is that Bran is even more powerful than both Jojen and the three-eyed raven (Brynden Rivers) in the way that he has both greensight and the ability to warg. With this combination Bran is even able to affect the past by warging into Wyllis, and eventually making him become Hodor, which proves “the ink is dry”. He also gains his fathers attention outside the tower of joy, and even gets touched by the Night king in one of his greensights. Bran believes he is eventually (with more knowledge) going to be able to rewrite history and that’s why he decides to go back and stop the Night king several times, but fails every time, ending up fulfilling the timeline-circle and taking the identity of the Night king himself.
The first time, he tries to prepare the Mad king for the white walkers and makes him (through the same whisper-method used to get Neds attention) prepare wildfire under King’s landing, where the white walkers attacked (this attack is in the future for us viewers). But Bran fails, as the Mad king goes crazy from the whispers and instead tries to burn the city.
The second time, Bran goes even further back in time (as he continiously learn his abilites he is able do go longer and longer back in time) to try discover how the others were defeated the first time. He fail again and instead succeeds to become Bran the Builder, building the Wall and securing his birth by building Winterfell and creating the words “There must always be a Stark in Winterfell”.
The last time, Bran goes back all the way to where the Night king was created, to warg into the human that later is going to become the Night king (or maybe even try to kill the children of the forest). He wargs into him to instead stop the “dragonglass into the heart”-event from happening (or maybe in his attempt to kill the children, he gets chosen as the vessle for the NK). Only he doesn’t think of that the children of the forest won’t recognize him from the future, and that they at that point are in war with the first men (he is gagged because of all the wierd future-talk). When he realized he failed again, he tries to go back in the current timeline, but can’t because he’s too deep into the past and stayed to long (“it is beautiful beneath the sea, stay to long and you drown”). From here Bran gets stuck in the past (exactly as Brynden and Jojen warned him not to) and becomes the Night king. With the combination of the children magic and Brans power, he becomes the villian instead of the hero he tried to be, resulting in turning against the children for creating him and getting stuck behind the magical Wall he later builds as Bran the builder.
Immortal as he is, he waits for himself to be born thousands of years later, knowing when and where he has to be to mark the young Bran, personally kill Brynden Rivers for hiding the truth about what would happen with him, and eventually being able to destroy the wall with a certain dragon. The reason the Night king doesn’t end his misery by killing his younger self, is that he finally learnt the ink is dry, and he would fail again. The reason he doesn’t kill Jon Snow, and instead observe him at Hard home (maybe even resurrected him at Castle black?) will be covered in the end. Ending up marching south and once again fulfilling his timeline which we will see in the following two seasons.