In the old days of analog tape recording tape decks or recorders had three head functions. One head printed (recorded) audio to a track, one head played back the audio printed to a track while a third head erased existing audio from a track.
Disable the erase head and a tape deck or recorder could print new audio on top of existing audio. Some tape deck and recorders had the feature built-in while studio engineers added a switch to decks or recorders that did not ship with the feature. When the feature was used, it was critical to plan ahead and keep a close eye on the recording level.
Guitarist and recording pioneer Les Paul is generally credited with inventing the technique. Here is an interesting website with more information and examples:
http://www.les-paul.com/timeline/sound-on-sound/