I went to Stanford and just graduated recently, so I remember being in your shoes as I thought about applying .
I also thought about majoring in mechanical engineering when I was applying, and ended up being a Computer Science major. I don't have a formula for getting into Stanford, but I can provide some of the things I did that may have helped me get in.
I worked on studying the SAT/ACT. When I applied, it helped to get a 2100 on the SAT or at least a 30 on the ACT. I took the SAT twice and ACT one, and didn't end up with the ideal SAT score. I submitted both scores still in my application. So in my opinion, these scores don't matter too much but I think it helps if you can get a decent score. I studied for the SAT during my rising junior year summer!
I would also focus on how to showcase your passions on your application. Stanford's application is different from most colleges because they have multiple short answer questions that emphasize passion in my opinion. Stanford wants to know why you are passionate about learning, and how you would contribute to the campus. I would think about how to showcase your passion and show that you constantly want to improve your intellectual vitality. For example, I emphasized my love for science through the numerous Carl Sagan videos I would watch on the weekends and how I ended up starting a robotics club in my high school. Think about how you can utilize your next summer to emphasize this in the application!
Grades are also important and I would try to maintain a good GPA through high school. However, I think Stanford likes to see that you are pushing yourself and so taking difficult AP classes will also emphasize your desire to learn and take on challenges. Personally, I maintained a 4.0 GPA throughout high school, but I have tons of friends at Stanford who didn't have 4.0 GPAs. There were only 6 AP classes in my high school when I attended and I took 3 my Junior year, and 2 my Senior year.
Try to stick with the clubs/activities you did from freshman/sophomore year. I noticed that many Stanford students were in the same clubs/activities for 3 or 4 years in high school. This can show that they are dedicated to their interest and are extremely passionate about these causes. I think being a well-rounded student helps in applying to Stanford.
Hope this helps and I wish you the best of luck in applying!