SPOILERS for GOT- You were warned.....How did you miss this? The entire episode (and as others have pointed out, series) was a build up to her doing so.
Arya’s training with Syrio made her quick as a cat and she already sneaked upon Varys and Illyrio in Season 1 but had gotten so good that by Season 7 she could sneak up on Sansa without even making a squeaky door give her away. This also makes sense considering her blind period in Season 6. Without sight, she had to rely on sound to get by and hear enemies. In Winterfell she successfully sneaked up on Jon, one of the most battle trained warriors in the world.
Those scenes, especially the one with Jon which is located at the exact same spot she sneaks up on the Night King, also inform you that Arya knows routes many perhaps don’t. And even if they do, she can navigate them without being noticed. This is amplified by her running through the halls of Winterfell. She knows this castle better than anyone. If anyone can sneak up near the Weirwood tree, it’s Arya.
The scene in The Long Night where Arya hides in the library serves the very purpose of your question. She can even sneak up on the dead is what the show tells us. She’s stealthy, silent and can deceive even mindless, fearless creatures such as wights. The scene exists solely to inform the viewer that by the time Arya jumps at the Night King, we already know she had the ability to sneak past White Walkers and wights.
A slight alteration also is that Arya doesn’t actually sneak up on the Night King. She very loudly announces herself by jumping at him. She sneaked past wights and White Walkers the same way she did in the library. But as Lyanna Mormont demonstrates, attacking someone bigger than you while screaming can have a benefit. You might be caught, but at least you’ll be close. The visualisation of Lyanna and the Giant informed us that even though a bigger creature can hold a little girl, said little girl will be in reach to stab him anyway. A stab we knew Arya could perform, because she showed off her dagger switch to Brienne in Season 7.
Then there’s the motivation. When Beric points Sandor to Arya, he deliberately points out her will to live. Arya has something to fight for, perhaps more than anyone she had already witnessed her family being slaughtered without being able to help them twice. And thus she fights with everything she has to stop it a third time. That willpower to live and fight for her home and family turned out to be a match for Death itself. Aided by Melisandre’s “Blue eyes” comment which gave Arya the extra courage that not only could she defeat The Night King, Melisandre foresaw it. And what she foresees, comes true. (A nice extra touch, since we viewers know Melisandre’s premonitions most certainly not always come true. Arya, however, does not.) And let’s not forget her journey with Beric and The Hound which ensured she lasted through the rest of the fight to do what she did.
The Long Night was as much an episode about how the Dead attack Winterfell as it was a story about how our little Arya could defeat The Night King.