"contrivance for catching unawares," late Old English træppe, treppe "snare, trap," from Proto-Germanic *trep- (source also of Middle Dutch trappe "trap, snare"), related to Germanic words for "stair, step, tread" (Middle Dutch, Middle Low German trappe, treppe, German Treppe "step, stair," English tread (v.)).
This is probably literally "that on or into which one steps," from PIE *dreb-, an extended form of a root *der- (1), base of words meaning "to run, walk, step." The English word is probably akin to Old French trape, Spanish trampa "trap, pit, snare," but the exact relationship is uncertain.
The sense of "deceitful practice, device or contrivance to betray one" is recorded from c. 1400. The meaning "U-shaped section of a drain pipe" is from 1833. Slang meaning "mouth" is from 1776. Speed trap is by 1908. Trap-door "door in a floor or ceiling" (often hidden and leading to a passageway or secret place) is attested from late 14c. (trappe-dore).