Personal unions can arise for several reasons, ranging from coincidence (a woman who is already married to a king becomes queen regnant, and their child inherits the crown of both countries; the King of one country inherits the crown of another country) to virtual annexation (where a personal union sometimes was seen as a means of preventing uprisings). They can also be codified (i.e., the constitutions of the states clearly express that they shall share the same person as head of state) or non-codified, in which case they can easily be broken (e.g., by the death of the monarch when the two states have different succession laws).
The Commonwealth realms are independent states that share the same person as monarch.
Because presidents of republics are ordinarily chosen from within the citizens of the state in question, the concept of personal union has almost never crossed over from monarchies into republics, with the rare example the President of France being a co-prince of Andorra. In 1860 Marthinus Wessel Pretorius was simultaneously elected as the president of Transvaal and Orange Free State and he tried to unify the two countries but his mission failed and led to the Transvaal Civil War.
Even though France is now a republic with a president and not a monarchy, it has nevertheless been in personal union with the neighboring nominal monarchy (non-hereditary) of Andorra since 1278.
For more information, see § Korea: Goryeo below.