In the end of Rogue One, it was obvious that the Death Star plans just had to end up in the hands of Princess Leia. It was a necessity in terms of continuity and storyline.
But from the in-universe point of view, it was confusing that she participated in the Battle of Scarif in the first place. As we saw earlier in the movie, her (step) father Bail Organa left for Alderaan from the rebel base on Yavin 4, specifically to send Leia a mission to meet Obi-Wan Kenobi. He even expressed his unconditional trust in her; that she would carry out the task. Still, she Leia joined the fleet in the space battle and endangered both her life and her mission.
Why did she do that?