A trap is a physical device or a tactic used to catch someone or something.
In 2366, when a science project of Wesley Crusher's went wrong and some nanites escaped his laboratory, he put small traps all over the ship, including Ten Forward, in order to catch the tiny nanites. He was successful and caught at least one nanite. (TNG: "Evolution")
In 2375, the Hazari apparently did not cover all possible flight paths the USS Voyager could take, but Captain Janeway was convinced those open routes were in fact traps. Later on, Kurros suspected Janeway had set up a trap when the Hazari were attacking the Voyager. (VOY: "Think Tank")