In the Declaration of independence, "the thirteen united States of America" is written with an under-case "united" implying that at the time, that was not seen as a name of a country, but as a descriptor of 13 "states" (which is often synonymous with "countries") working together in union, similar to the EU. Was it not until the Constitution in 1791 and the end of the articles that the US saw itself as one nation?
It actually took much longer than that. The 1787 Constitution was a big change in governmental power, shifting more power to the Federal side than anybody had dreamed of 10 years earlier; but still each state had its own government, and a someone from Virginia would identify themselves as Virginian rather than American. Some would argue that the states still aren't fully unified today. From time to time you see one or more states flexing their sovereignty. For example, Utah refuses to do daylight savings time, and Colorado and Washington just legalized marijuana.
The writers of the constitution never intended for the line between cooperating states and federal government to disappear, and their ideas have been upheld for the most part. One big influence, though, was the Civil War. At the time, the country was commonly called the Union, a reference to the sovereignty of each state in the federation. After almost half the country seceded, this idea was forced to change. Before the war, in his first inaugural address, Lincoln used "the Union" twenty times. After three years of civil war, the Gettysburg Address did not have one mention of "union" but instead said "nation."
After the war, the main factors for uniting the states were railroads, radio, and the telegraph. These led to faster travel and communication between the states.
Source: University classes and Made in America by Bill Bryson