Many SF novels feature a World State encompassing the entire Earth. Such imagined states can have various origins. This is not surprising, since advocacy for World States (from persons on the Left, Right, and entirely outside that framework) goes back centuries and more.
Sometimes, as in Star Trek, it is “a dream that became a reality and spread throughout the stars.” Sometimes it is formed out of desperation: in Poul Anderson’s Tau Zero, humanity united under Sweden on the grounds that Sweden was
big and modern enough to make peace-keeping a major industry; but not big enough to conquer anyone else or force its will on anyone without the support of a majority of nations; and reasonably well thought of by everyone.
…And because the first general nuclear war left the impression that the next nuclear war could be the last one ever. Handing a single authority the keys to all the nukes seemed the best solution.
And sometimes, as in Vernor Vinge’s The Peace War, it’s a naked power grab: a small group of people setting themselves up as the world’s supreme power.