Fame counts big time, but it's not the only factor. Big studios look for actors who already bring an audience with them, because it reduces financial risk - a recognizable name helps sell tickets and attracts investors. But that's not enough. The casting director checks if the actor fits the character: the physical appearance, sure, but especially whether they can actually pull off that specific role. A really talented actor might not be right for a part that requires a certain kind of charisma or presence, and vice versa. Then there's the screen test thing: lots of actors do auditions and some get rejected just because the director doesn't see that "spark" they're looking for.
Connections and networking count way more than a lot of people think, honestly. Who has a good agent, who's already worked with certain directors, who's friends with the producer... all of that opens doors. It's not fair, but that's how it is. Lots of talented actors stay in the shadows because they don't have that network of contacts or because they happened to be in the wrong place at the wrong time. And sometimes the timing of an actor's career matters too: an actor could be perfect for a role, but if they're in the middle of shooting other films at that point or just had a flop, studios might prefer someone who's more available or has a fresher reputation.