On July 2, 1776, the American Colonies legally separated from Great Britain by a vote of the Second Continental Congress in closed session, approving a resolution of independence. The day before, in a letter written to his wife, John Adams predicted,
“The second day of July, 1776, will be the most memorable epoch in the history of America. I am apt to believe that it will be celebrated by succeeding generations as the great anniversary festival. It ought to be commemorated as the day of deliverance, by solemn acts of devotion to God Almighty. It ought to be solemnized with pomp and parade, with shows, games, sports, guns, bells, bonfires, and illuminations, from one end of this continent to the other, from this time forward forever more.”
So how come we celebrate on the 4th? Because having voted for independence, the same congress immediately went on to draft a formal explanation of their decision and didn’t complete and approve it until the 4th. Since that date is clearly evident on the document itself, which itself had been widely publicized, by the time the next year came round it was the 4th of July that stuck in Americans’ collective memory, not the 2nd, and thus, that is the day we have celebrated our freedom ever since.