Nobody built that step. The training task was only ever guess the missing word from its neighbours, and no part of it mentions gender, or royalty, or relationships of any kind.

It happens because every example tugs at the vectors at once. Words that keep the same company get tugged the same way, and a relationship that shows up over and over ends up as the same step wherever it applies.

A relationship between words can become a step you can take, and the same step works for every pair that shares that relationship.