As others said, you need to be fascinated and willing to dive deep, obsess (in a positive way) over details, tinker, play around with code/materials/math...
For example I study programming language source code, kernel source code, hypervisor source assembly, gcc, LLVM, other compilers, write my own compilers, interpreters and study Assembly Language and tech specs for different architectures. My peers always wonder how I am so accurate in writing such high performance software. Well, what they don't know is I know what is going on under the hood literally down to the assembly and how what is written is processed through the chips, copper, and other elements on the board and other connected components.
I just really enjoy knowing how things really work and even better when things go wrong because I have the ability to debug down to the hardware level if necessary to fix the problem even on brand new hardware I have never seen before. As sometimes the performance or security problems are not a software issue, but a hardware issue that is holding things back or leaking secrets.
The challenge of solving hard problems is what gets me into studying which makes it fun and exciting to me as I know learning something new is just around the corner. Nothing like reading RFCs, SPEC sheets, NIST docs and more to help see the different ways things have been documented vs the actual implementation, what security loopholes were done and why there were done (mostly in the name of performance gains) and other things that the majority of people do not know of due to it being undocumented, improperly documented.
Key is to find a way to make the subject at hand somewhat of a challenge to help keep you motivated and push through it. Other engineers and scientists know that feeling of finding a breakthrough or truly understanding how something really works and that ability to squeeze every drop of performance out of something is amazing after putting in the time to study. If in the academic setting, professors respect those that can dive deep and show true mastery of the subject at hand. As most people only scratch the surface of the tech they use every day as deep understanding is not always required, but sure does bring a whole new level of fun to using or creating tech.
Not sure how their grades would have been without this studying, but they did fine with it.