I don't think it ends at university. I have been in IT a while but am somewhat new to my stack, and had trouble two years ago when interviewing, a number of companies passed on me. I got hired at a decent salary but don't want that to happen again so I have been studying. I am more in control of my timeline, and have been studying, but I want to be in a better place if I want to look around in a year.
So for your choices of learning to improve quality of knowledge or doing what needs to be done to pass leetcode, my choice is to do a little of both. I am studying for the things they may give me on an interview (work samples to complete, 30 minute coding exercises, whiteboard class design etc.) But I am not doing it in a shallow leetcode way where I just want to know enough to pass the interview.
If I am building something akin to the complexity of a given work sample, I want to understand the architecture of what I am handing in, the language aspects of it, how the unit testing works and what to unit test and all of that. To have a deep understanding of it, or at least more than a surface leetcode understanding of it. If I am new to the topic I try to get some grasp of it, move on, and then sometimes I revisit the topic in the future to deepen my understanding of it.
So the immediate ends of a lot of what I do in my spare time is to prepare for the interviews I may have in a year. But one aspect of it are that I will spend a little time if needed to learn things which may not be asked in an interview, but which would let me do a better job at my current job or next job, or even if I want to write a program on my own. Another aspect of it is that I spend the time to try to get a decent enough understanding of it before moving on, not just enough that would pass over the leetcode bar but not into a slightly deeper understanding. So the main aim is passing an interview, but I will take the time out to learn things to improve my work, not just interviewing, and to deepen my knowledge of the subject as well.