A trap is a form of underhanded attack intended to catch targets off-guard, granting the trapper the initiative and advantage over their opponent. Traps can also be security features designed to prevent entry into certain areas by making sure that trekking through them is a perilous affair.
Speaking of affairs, the beardiest of us have established that a woman is the perfect physical representation, the definition, of a trap. Not always deadly, but definitely the most effective, as there is no possible way of freeing yourself without internal or external damage.
In-game, traps can either be devices designed to strike opponents unexpectedly like pitfalls and landmines, cunning tactics like ambushes and assassinations, or fighting moves like riposte or feinting. The main gist of traps, however, is that they must not be discovered before they are needed. Otherwise, most people can avoid traps and render them useless before they do their work. It may even work against the trapper and put themselves in a dangerous position instead.
In RPGs, a trap can either be a devilishly evil contraption that the GM placed into a campaign to trick the players or to somehow outsmart them (and hopefully kill them later) or a piss poor trick that a lobotomized retard could see right through.
A rather badass type of trap is a bear trap; either a pair of spring loaded mechanical jaws, or a trap that releases a hungry bear.
Traps are a staple in Dungeons & Dragons. They can take the form of anything from a spring loaded blade on a door, a pit full of spikes covered up by a net, an illusory wall or many others. It is generally used to screw with the players. The rogue in 3.5 and down is, pretty much, the only class that can deal with them, while in 4e anyone can effectively if they choose to work on that skill. The latest edition lets anyone with thieves' tools proficiency go to work on 'em, though rogues and bards both get specialized tricks to make them best at it.
Traps have become a widespread term used in places like /a/, /b/, /cm/, /d/, and /h/ to describe young crossdressing males and drag queens, who outwardly appear to be a cute girl. The trope has slowly but surely gained more and more popularity in anime over the years, and has divided the fans' stance on the topic, with some staunch detractors and adherents from all walks of life.
Less common is the "reverse trap": an extremely tomboyish girl whose generally small curves allows her to, intentionally or otherwise, pass herself off as a man.
The term also carries the same legacy as 'fag', which is one of the main roots of the aforementioned division: using it in normal social situations guarantees people are going to take offense ('Trap' is used as a derogatory term for transgender people in the same vein as 'fag' is used to demean gay folk. Though if you needed us to enlighten you on that, either the ball was seriously dropped or you didn't care all that much to begin with). On the other hand, there are people comfortable with being called a fag/trap, either because they understand when it's being used in a non-insulting context or they identify with the terms fags/traps and enjoy the bonding act of shitting on their friends.
The Japanese term for this is 男の娘 (otoko no ko), literally "daughter that is male" (not "Daughter of Man," it's a common newbie mistake to think "no" always means "of"). This is a pun on 男の子, which is pronounced the same, but is just a catch-all term for "boy", literally meaning "child that is male".