Hi Jackal_h,
That can happen for many reasons but for one reason in particular, namely bad luck. People all have their on-days and their off-days, and they occur randomly, so doing well or doing poorly is almost purely due to chance.
Studying, prayer, and pacing, also influence the outcome but to a lesser degree.
Thats why its always important to wish people the Best of Luck immediately before an exam.