Clearly this is a complicated question and don't think there is widespread agreement about it in philosophy. My own take is that we should think of language that picks out entities in possible worlds as indexed de re to the relevant object in the actual world. We can contrast this with the theory that identity of entities and their possible counterparts is done de dicto by similarity under some weighted set of properties.
To understand the de dicto/de re distinction consider a simple example that does no involve possible worlds (at least not explicitly):
While, I'm organizing my bookshelf I notice that a book has been jammed in between the couch cushions. Being lazy, I ask my wife, "could you get me my copy of Reasons and Persons over there in the couch". She lovingly goes to get the book, but lo and behold when she pulls it out, it is not Reasons and Persons after all but rather The Girl with The Dragon Tattoo. She hands me the book. Now, if I was referring to the book based on the logical extension of the description (de dicto), "my copy of Reasons and Persons over there in the couch" then the book I was handed was not the book I meant because it lacked an essential property designated in the description of being a copy of Reasons and Persons. However, more likely, I was just using the description "my copy of Reasons and Persons in the couch" to indicate the actual book I wanted her to get which as it turned out was The Girl with the Dragon Tattoo. My description was de re, the correct reference was based on the nature of the actual thing being indicated not a logical extension based on a set of properties given in a description.
How is all this relevant to possible worlds and Alex? When I say something like, "Alex is a lawyer in the actual world, but it is possible for him to have been a philosopher if only he'd not been pressured into law by his parents." A modal logician would model the meaning of this statement with a non-actual possible world w in which Alex is a philosopher due to having received less pressure from his parents in the past. You are asking, how do we know that philosopher Alex in w is the same person as Alex in the actual world. If we understand "Alex" as an abbreviated description, something like a weighted list of Alex's Alex-making properties, then clearly the Alex of world w and the Alex in the actual world both meet a large number of the properties on the list.
One account of transworld identity says that we should generate a weighted list of world-independent Alex-making properties which pick out Alex in the actual world. Then looking at all the entities in world w, find the entity that is the most Alex-like. As a caveat we can say that if no entity is sufficiently Alex-like, then we say that Alex does not exist in w. This is roughly a de dicto account of transworld description. It treats a possible world as an extensional totality, i.e., as just like the actual world in its logical structure except for the fact that it lacks the property of actuality (some even say that the property of actuality is merely relative to a chosen world where we evaluate the truth of non-modal statements).
An alternative is to see our talk of possible worlds as intensional and our ability to refer to entities in possible worlds as de re. When I refer to Alex in world w, I know it is Alex because I intended to talk about a variant of actual Alex. I am not discovering the Alex of world w as if I'm visiting an alien planet, I'm talking about a way that the actual world might have been if things had gone differently. When it comes to modal reference there is no need to act like a scientist and go searching for the most Alex-like entity in the whole universe of world w. After all, world w isn't a physical entity, it is only a logical construct necessary to build a semantic model of modal language. I get to automatically import my ability to refer to Alex from the actual world into any possible world (although in some worlds there might be no reference entity available).
Let's consider an example where the de dicto and the de re account could have different implications. If I say, "It is possible that Alex could have been born 10 years earlier than he in fact was." Now, if a certain account of personal identity is true, on one might think that anybody born 10 years earlier would not be the same person as Alex. We could imagine a person just like Alex in terms of appearance, personality, etc., but (barring time travel) this person would have originated from a different sperm and egg, so he would be numerically a different person. However, on the de dicto account of transworld identity, the older clone of Alex might be identified as Alex in world w, because older "Alex" is the entity in w who is most similar to actual Alex. Crucially, the older "Alex" does not lack any of the essential features for being the kind of thing actual Alex is (i.e., being a person). Viewed extensionally/de dicto there is no way to tell that older "Alex" is not a possible version of actual Alex.
On the other hand the intesional/de re account would say that when our language reaches across to another world, the meaning of that language is fixed by the actual reference entity (in this case actual Alex). Thus, when we consider the older "Alex" we aren't just matching entities of w against a world-independent basket of properties, we are determining whether older "Alex" is a possible way that actual Alex could have been. In this case we might determine that older "Alex" is merely a time-shifted copy of actual Alex, but not a possible version of Alex himself.