Erebus sorts the starting locations and tries to give each nation a location that 'fits' them best thematically (dwarves in hills, etc.)
Otherwise, the scripts try to find a good starting position for each player. Usually, the algorithm is to pick the best position first, then the second best for the next civ (civs are shuffled before), etc.
There are weighings of all kinds. In tectonics, I bias the computation so you're more likely to start on a continent where there's already someone in order to avoid isolated starts.
Describing the algorithms in English is not really easy and I don't remember precisely, but you can check the source code in tectonics for instance. Erebus I think only shuffles afterwards but may not change the algo, although I'm not sure.