Everything plays a part, including luck, but it’s a spectrum.
As others noted, we have privilege of not growing up in a third world country. So we are already ahead of others from birth.
Then your living conditions growing up come into play and what opportunities these gave you. Schooling, extracurriculars, networking etc.
Another factor is down to individual motivation. You can have all the opportunities available to you but if you don’t take advantage of them, you won’t get anywhere.
You also have to consider the person themselves- if they were born with a disability, or any other concerns which may cause an obstacle in their lives. That adds an extra layer of ‘difficulty’ that others don’t have to experience.
You have an unconscious bias if you are not a stereotypical white male, or even if you are you might feel set aside for D&I targets (I’m not commenting on this to say it’s wrong, just acknowledging it could happen and cause a disadvantage even if it might be positive).
Then you might also have just been in right place, right time. Who knows.
Some people might have ‘luckier’ circumstances than others, but I wouldn’t devalue someone’s personal efforts down to ‘just luck’ as that is just as bad as saying someone is in a poor situation because they aren’t lucky, when actually, they might have just not explored opportunities available to them and be content to claim they were ‘hard done by’ when they simply didn’t want to try (for whatever reason that may be).