The best advice I got starting out was, "be indispensable."
The best advice I got four years later was, "don't be indispensable."
In a growing company, the indispensable people may find themselves being left holding the bag while new initiatives are undertaken. I very quickly learned the meaning of 'working your way out of a job' after the first time this happened to me.
I'm sure there's some min-max game I'm not playing with regards to how easy I am to lay off, but once I learned there are worse fates that being laid off, I stopped looking for them. Being "stuck" with responsibilities is unpleasant when things are going well, but it's miserable when things are going badly. If you aren't the one who got laid off, then someone you used to trade off with doing onerous tasks certainly was, and now you're stuck doing it every single time.
If given the choice between "my company would be just fine without me" and "everything would fall apart if I didn't show up to work," the latter feels very good for a brief period when you're young, until the weight of that responsibility sinks in. "My company would be just fine without me," can mean "my work here is done," and you can ride off into the sunset with a clear conscience.