Regarding the secret internship, when professors obtain funding for a summer position they typically do not advertise these positions widely if they already have someone in mind. And the person in mind doesn’t need to be the top student in the class (but would not be the worst student, either.). Being in the right place at the right time is part luck and partly due to networking.