My daughter was asked to do research for a professor. He didn’t advertise the job, just picked who he thought would do a good job. Daughter wasn’t top of the class, and maybe other students (like you) thought the job should go to the highest grade in the class, but that’s not how it works.
The profession probably chose based on attending class (on time), work put into problems, being a nice person. Prof needed someone reliable. He had a deadline for the project and knew she’d meet that deadline. She did, even though she had the flu (twice) that semester, had her sport to play, had her senior project to finish. Some traits are more important to the employer than just being the best at something.