The Declaration of Independence was approved/signed on July 4th, but it was two days earlier that the Continental Congress Passed the Lee Resolution:
Resolved, That these United Colonies are, and of right ought to be, free and independent States, that they are absolved from all allegiance to the British Crown, and that all political connection between them and the State of Great Britain is, and ought to be, totally dissolved.
That a plan of confederation be prepared and transmitted to the respective Colonies for their consideration and approbation.
On July 2, the resolution of independence was approved by twelve of the thirteen colonies. Delegates from New York still lacked instructions to vote for independence, and so they abstained on this vote. Even then the NY Legislature was a joke.
After voting for independence on July 2, Congress turned its attention to the declaration. Over several days of debate, Congress made a number of alterations to the text, including adding the wording of Lee’s resolution of independence to the conclusion. The text of the declaration was approved by Congress on July 4 and sent off to be printed.
John Adams wrote his wife Abigail on July 3:
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.
Adams was off by two days. From the outset, Americans celebrated Independence Day on July 4, the date the much-publicized Declaration of Independence was approved, rather than on July 2, the date the resolution of independence was approved in a closed session of Congress.