---general definition---
It's not easy to pinpoint where "trap" came from or what it means to internet people. I try to summarize it like this: a "trap" is a person who's assumed or mistaken as female, based on clothes, behavior or physical appearance who are stereotypically categorized as "feminine".
The way it's often depicted, a "trap" is "trapping" a person in the sense that the person gets attached (or falls in love) with the trap, and only afterwards learns about the trap's male gender identity or male genitals, when it's "too late" and the person's heart got "caught" by the trap, causing confusion and eventually "oh whatever: I love him how he is and how he feels happy".
IMO, this makes traps "trans-allies": the other person questions their stereotypes and becomes aware of the difference between gender identity and gender expression, and thus becomes may more understanding about trans people and the broader LGBTQQIAAP+ communities.
---traps vs. crossdressers---
There is a huge difference between traps and trans women: gender identity. Traps remain in male gender, whereas trans women identify as female gender. For many people it's very confusing because they assume that gender expression and gender identity are the same. This confusion sadly leads to mockery especially against transvestites/crossdressers, or formerly drag queens.
---now, to crossdressers !---
The definition is very simple: a person who wears stereotypical clothes from the opposite gender expression.
IMO, traps are implicitly crossdressers: what makes them "fall into the trap category" is the feminine cloths. In fact, without clothes or with neutral/masculine cloths, they wouldn't confuse the person about their gender identity.
BUT: crossdressers may not be confusing about their gender (not be perceived as female), thus not being a trap.
---trap as slur---
Lastly, a quick word about "trap" being used as a slur: some traps genuinely do it for the fun of confusing people (up to "playing with people's hearts"), some do it as political message to highlight and denounce gender stereotypes, the reasons doesn't really matter, if there is any. After all, I also crossdress for cuteness, fun and political statement, even if I only do it at home and for the internet.
Point is: it doesn't really matter by who the "trap" word was created or who it targeted, it is now a word gathering a community of members and/or supporters, and so the word should be embraced and claimed. Just like the "queer" word was, in which "trap" is a sub-category
Misogynists constantly invent new words to insult and shame LGBTQQIAAP+ people, so we gotta fight back by overturning the words, and be proud of who we are and what we do, sending a strong message to all people who don't feel "fitting the gender-binary norms" that they are not alone, that they are free, and that they are welcome under the rainbow !