Habitual residence holds sway.
Some countries, some of the time, may prioritise smallies being primarily with their mother. But typically it comes down to where are the children habitually resident.
The parent who comes from somewhere else, and wants to go home, has to make a choice. Go home without the children, or stay and have the children (at least some of the time).
Just a heads up for anybody in an international relationship which may result in future children/ existing children living in another country at some point. Do not bank on any “mother card”. Make your plans based on the worst possible outcome (which will depend on the country, visas and right to work can be an issue post split) and be sure you can live with that.
The same applies to anybody considering becoming a trailing spouse.
No matter how you feel that children should be with their mums, and the mums should be allowed to take their children where they can/want to live and work, courts all over the world don’t work like that.
Don’t go anywhere you can’t manage being until your youngest child is 18. Bear in mind that once 18 your children may still want to remain where they grew up and have very little attachment to the place you call home.
I’m not saying don’t do it (I did it, and it’s been great, if a bit nerve racking during the normal ups and downs of a long marriage). But know the frying pan you are climbing into in its fire form BEFORE you make any potentially permanent moves.