Originally a phrase used when an alcoholic resumes drinking. The wagon is presumably the high school or college band wagon. In the 1950s, schools used to hold pep rallies for football teams. Often the music band would be on a wagon and the enthusiastic students would hop on the wagon. Alcohol was not allowed on the wagon. The phrase "back on the wagon" refers to one who quits drinking and hops on the band wagon, with a positive spirit, supporting the team and school. In other words, one who is happy to not drink. Relapsing into alcoholism is often sudden and unintentional, hence the description of falling off the wagon.
I guess John fell off the wagon last night, he was hammered.