Now, in my theory, it isn't neccessarily due to an alien invasion, just alien contact. I have limited nerdiness in regards to Star Trek, but I remember seeing (and enjoying) First Contact, where they go back in time to ensure that the Vulcan notice them, make contact, and the future is a wonderful thing with the Federation and whatnot. But its like that. Granted, if the aliens are hostile, then of course we're going to unite to defeat them. But even if they "come in peace" the world will still unite as one planet rather than a couple hundred nations.