AITA for unintentionally laughing when my friend told me about her grades?

For starters, I am a medical student and a very competitive person. I have been competing with others, especially the ones in my close circle, ever since I was a kid. I am not proud of it, it’s just the way I am. I also have this problem where I laugh in uncomfortable situations, usually for a second or two before I regain composure and act according to the situation.

Two days ago, the results of our latest exams came out and I got a decent grade despite it being just a little bit lower than what I was aiming for, when I asked my friend (we are not best friends but we get along great) about her results she told me that they were bad and that she spent the day of the results crying, she is very intelligent and hardworking so I am guessing that her grade isn’t that bad but like me, lower than what she was aiming for. The moment she said that I felt the laughter bubbling out of me but I stopped it immediately when it was just a grin and not a complete laugh.

Till this moment I am not exactly sure what the exact cause of the laugh is, was it because I am competitive and felt joy when I learnt that I wasn’t the only one who didn’t get the grade I was hoping for? Or was it just my laughing in inappropriate situations problem? I am not a cruel or a sadistic person, on the contrary, I’ve helped this specific friend with studying before and was praying for us both before the exams.

Now, I am pretty sure that she caught me grinning because she seemed pretty upset for the rest of that day and when we met again today she tried to ignore me without being outwardly rude and didn’t have that friendly demeanor towards me that she always has. I am not sure what to do, should I directly apologize to her and explain the situation although she hasn’t brought it up? Or should I try to stir our next conversation into that incident and explain it? Also, what should I tell her? That I was relieved to know that I wasn’t the only one who wan’t satisfied with my grade and that I had no ill intentions towards her and feel sorry that we both weren’t able to get our desired results, or should I tell her about my laughing problem and hope that she’ll understand that it wasn’t intentional and that I am not happy that she is disappointed in her grade? (knowing that she is a serious person)