Well, there's no single answer.
The writer sells to the publisher with the best offer, which may be a single publisher with a take-it-or-leave-it deal. It wouldn't make any sense for an author to sell all foreign rights to a publisher who has no ability to sell in foreign lands, so an author's agent may negotiate to keep those rights and sell them separately. Or the publisher may buy foreign rights and parcel them out to foreign distributors.
When I worked for Disney, they bought all rights throughout the Universe forever. I thought about limiting them to "rights within the Milky Way Galaxy only" but decided not to force the issue.
Anyway, doesn't it all date back to the days when sales were assigned geographically because everything was hand-sold? The geographical restrictions made sense when the salesmen were schlepping around trunks of books. Not so much anymore.
When authors are
truly in charge (and not in thrall to a publisher), they own all rights and can offer their ebooks anywhere in the world. Or the Milky Way Galaxy. Or the Universe.