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.
Alexander Freed's official novelization explains it.
Leia's ship (Tantive IV) was being repaired from earlier (unspecified mission caused) damage
As it was docked in Produndity's hangar; it was carried to Scarif when Admiral Raddus urgently took entire fleet to Scarif
As it wasn't in a condition to fly, Leia had no means to evacuate even assuming she wanted to (and being "let me take the blaster from Han Solo and shoot the wall and jump", I doubt she would have wanted).
The Tantive IV wasn’t ready to fly, let alone fight. It had been the subject of frantic repairs during the lightspeed voyage from Yavin to Scarif, secure in the hangar of the Profundity where it had lain, stubbornly malingering, since its last mission. Even after its host vessel had arrived in-system and joined the battle against the Imperial armada, Captain Raymus Antilles and his engineers and droids had worked desperately to make the corvette spaceworthy—to seal the leak in its hyperdrive motivator and clean the buildup in its exhaust ports. Admiral Raddus had made the situation clear: Every ship in the fleet had a part to play.
Raymus loved his ship. He’d nearly lost it once. For the Rebel Alliance, he would risk losing it again.
But the battle over Scarif had ended before the Tantive IV could join the fray. Just as the corvette’s reactor had come to life, the Profundity had screamed with punctured metal lungs. The Tantive IV had rocked in the hangar bay, nearly dislodging the boarding ramps clamped to its air locks.