You're most likely to get credit by being unique and irreplaceable. In other words, if the work would not have happened without you. If someone else could have been easily hired to do the work you contributed, and if in that case the work would have been largely indistinguishable from the work you did, then you're essentially fungible.
IMO you still deserve credit. And in fact you still get credit. But that credit comes in the form of monetary reward and (hopefully) recognition from your team and peers, rather than in the form of fame.
All of which… seems sensible to me? Hard to imagine it working otherwise. Interestingly, the movie industry has normalized "end credits" which play after a movie ends, and which lists literally everyone involved, which is quite cool. But the effect is still the same, the people up top get 99.99% of the credit.
(Ofc the "system" is imperfect, and fame/credit can be gamed by good marketers. But it's also not a "system" that any one party invented, it's just sort of an organic economy of attention at work.)