They are a trap though. You think they're a girl, but then they turn out to be a boy. That's like the basis of all traps, you think you're getting one thing then you get another very unpleasant thing.
It's still offensive though. It's not their fault they werent born girls and if they identify as female, calling them a trap is like a slap in the face. Even if they don't identify as female, it's still not something you should call someone. And no, it's not a "trap", it's a simple misunderstanding. You say it like these people are doing something wrong.