Taps is based on an 1809 French bugle call ("Tattoo"). It was used to signal lights out and go to bed. Napoleon referred to it many times as his favorite bugle call (actually played on a clarion, which is one of those really long, straight trumpets you see being played in movies to herald some king during the Medieval Times or the Renaissance). The call was used by the military up until the Civil War.
But, General Daniel Butterfield thought that that particular call was just a little too formal-sounding to end the day. So, in 1862 he decided that he would revise that bugle call to something shorter and simpler. Butterfield got his brigade bugler, a 22-year-old by the name of Oliver Wilcox Norton, to help him revise that earlier bugle call into those 24 notes that we know today as "Taps."
It was an instant hit. Nearby brigade buglers heard it and visited Norton the next day to learn the call. The call was quickly put in place by other brigades, as well as by Confederate brigades. Without there ever being a general order issued by the Army, the new call replaced the regulation call by the military. It wasn't until 1874 that the Army Regulations were changed to reflect "Butterfield's Lullaby" as the official music for funerals and end-of-life lights out.
The custom of playing taps at military funerals began in 1862 at Harrison's Landing, when Captain John C. Tidball, commander of Battery A, wanted to give a particularly outstanding corporal a burial with full military honors. But he was refused permission to fire the traditional 3 guns over the grave while on a battlefield. He decided to have Taps played, instead.
So it was Butterfield who gave us the Taps we know today, and it was Tidball's Company A that gave us the tradition of it being played at military funerals.
I know this as the son of a Navy bugler, as a former Boy Scout bugler, and as a trumpet major in college.