What do you mean he held a secret internship? Do you mean he choose one person to be an intern and didn’t ask others to apply? That’s not uncommon. This is why you need to develop relationships with your professors. There not going to necessarily pick the student who has the highest grades, but rather the student that they know and like. This student may have expressed interest in the prof’s research. Maybe they met and discussed this during office hours. You really don’t know the whole story.
You can’t let one little thing like this get to you. Stuff like this happens to everyone and will continue happening you whole life. That’s just how things are. There aren’t many adults who can’t tell a story about not getting the job or promotion they feel they deserved. You have to just keep doing your best. But you do have to do more than just do the homework and get the grade. It’s not kissing ass to get to know your professor. Relationships and connections are very important in life and maybe it’s time for you to start working on that.