Why was I snubbed for the internship I had applied for?

So I was applying for a developer internship at a company, I passed the first interview and was called for a technical test.
I was given 70 minutes to complete a 3 programming exercise, I delivered fully working programs within 30 minutes. Showed charisma in the interviews and displayed all qualities a company may need.

But in the end, I wasn't chosen and the choice they went with is a classmate of mine.
I am happy for her and don't wanna sound like a sore loser but she told me she didn't finish the test on time and the exercises she did finish had errors in them, she's also very introverted and shy so now I am confused.

What I am interested in is knowing what it was that made me not the right choice so I can fix it for later this is by no mean a rant but a request for assistance.

Note: I am 23 finishing a Masters's degree. She's my classmate but she's 27 and worked for 3 years before going back to study.
I am also at the top of my class when it comes to grades and she comes in second (but not a close second, have almost double her grades and that of everyone else, again not flexing these are statistics)

Thanks for giving me professional insight that can be useful for future interviews
Why was I snubbed for the internship I had applied for?
Add Opinion