A few days ago I met up with the professor from the lab at Stanford where I worked in high school. I had a pretty rough fall semester, and I felt totally unmotivated and lost, so I wanted to hear what an Actual Successful Scientist had to say on the subject.
We spent nearly two whole hours talking, and his message boiled down to: "Mentorship is the most important thing."
This Ur-message applies, or has applied, or will apply, to my life in many different ways. I'll do my best to summarize here. (Context: I'm currently aiming for grad school and academic research, but considering alternate careers. In particular I have half-formed intentions of taking a gap year after I finish undergrad, and working in industry to see what it's like.)
If you have good grades, lab experience matters more than improving your grades. I have a very good GPA, mostly because I still have the overachieving high school student complex. I'm a perfectionist and I prioritize classwork above everything else. Last semester, I prioritized classwork above continuing my research from the summer, which was a big mistake. I was trapped by the subconscious impression that I absolutely had to maintain my very good GPA or else... what?
Really good lab experience, including good mentorship, is harder to come by than well-taught or interesting classes, and much harder to come by than an A+. It also yields greater benefits later on. I had to take this part on faith a little, because I haven't been to grad school, but it seems very plausible. "Lab hands" are very hard to teach, but a small gap in knowledge is easily corrected.
This is going to be really difficult for me to implement, because I'm so well trained at Being A Student that it's difficult to even imagine doing anything else as a primary occupation. But it has to happen eventually, and it may as well happen now.
The best mentors are those with proven track records in both scholarship and mentorship. It's often said that there's a tradeoff involved in choosing an older or younger advisor for your Ph.D.: the older profs are better mentors, but the younger ones are doing all the exciting new stuff. From what I remember of our conversation, and also a little bit from my own experience, I understand that well-established advisors beat young flashy advisors hands down.
A lot of this apparently comes down to having observed the most common failure modes in one's students. My prof was able to advise me particularly aptly because he's seen many people go through similar struggles to my own. It wasn't that he had seen my exact set of problems before; it was that he had seen parts of my problems in many other people and was able to synthesize them. He had something cogent to say about gap years, about engineering vs science, about depression, about grades, about anything I cared to ask.
A diverse lab environment is better for everyone. This goes hand in hand with the previous point: the greater variety of problems a mentor has seen before, the bigger the library of memories they can draw on when advising someone with the same problem or a new problem. (Not to mention issues of sexism etc, which are also very important.)
Finally, never hesitate to ask for help. People who can give good advice love to do so, because it makes them feel helpful and all warm and fuzzy inside. People who don't wish to give you advice may ignore you or brush you off, so there's basically no harm in asking very widely. It took me years to accept that my parents might occasionally have something wise to say, but it's true. Now that I've reached the point where my parents' academic/career advice is no longer particularly helpful, I have to cast a wider net -- but it's crucially important that I actually do so, and not rely on assumptions or PhD Comics.