Some official and unofficial maps of the Star Trek galaxy depict space realms like the Federation or the Klingon Empire, etc., spread out over a large proportion of the galaxy. Maps often depict each realm coving maybe 1 percent to 10 percent, for example.
The Milky Way Galaxy contains at least 100,000,000,000 star systems. So 1 percent to 10 percent of the volume of the galactic disc of the Milky Way Galaxy would contain at least about 1,000,000,000 to 10,000,000,000 stars, and possibly a few times that many.
So I can imagine that each star system within the Federation has a local system government, and that each group of 10 systems has a second level local government, and that each group of 100 systems has a third level government, and that each group of 1,000 systems has a fourth level local government, and that each group of 10,000 systems has a fifth level local government, and that each group of 1000,000 systems has a sixth level local government, and so on.
Obviously there would probably be many levels of government in a space federation or empire which ruled even one percent of the milky way galaxy. And there should similarly be several levels of local government within a star system and an inhabited planet within the system.
In the USA there are four levels of government that provide different services. Municipalities, which usually provide utilities, countries which keep records of wills and deeds among other services, states which make most laws and which issue driver's licenses, and the federal government which fights wars among other things.
In the later Roman Empire there were 5 or 6 levels of government. Pagi, subdivisions of civitates, civitates, which were city states with elected councils and magistrates, provinces with appointed governors, (secular) dioceses with appointed vicars, four praetorian prefectures with praetorian prefects, and the empire as a whole.
So if the United States of America joined the United Earth, presumably some of the functions of the federal government of the USA would be taken over by the United Earth government, but the Federal government would keep some functions, or share some functions with the United Earth government.
And presumably the same thing would happen when the United Earth joined the United Federation of Planets.
So it is perfectly reasonable to assume that the USA still had a functioning federal government with some functions after joining the United Earth and after the United Earth Joined the United Federation of Planets.