Hoping to die before your friends
I mostly see it as egoistic when someone hopes to die before their friends. What they often mean is "I don't want to experience the pain from loss of my friends. This pain would be too great for me to endure". What they are effectively saying then is that they want to transfer the pain of their death onto their friends. They are no longer here to experience anything, but their friends will mourn their death and suffer because of it.
But there can of course be differences in the intention.
Someone could mean that they hope that their friends live a long and healthy life and should live as long as possible because life is precious. The focus is more on the longevity of the lifespan of their friends and not on the shortening of their own life to die before them. The life of the friend has priority, not the transfer of suffering and therefore reducing your own suffering.
Or look at it like this: If you could see into the future and know exactly when a friend would die, you probably would do anything to extend their life. But if you would know your own date of death and also that of your friend, would you shorten your own life so you could die before your friend (if that would be the only option)? That seems stupid.
Being left behind is often the harder part (if the death itself is not a cruel, long, and painful process). I don't want my friends to experience that.