There could be multiple reasons why they do this.
- They are miserable and want others to be too.
- They are scared of losing the gender binary because either they won't know what to do with themselves or it benefits them.
- They are secretly trans or queer in sone way but cannot admit it.
- They have years of trauma and thus this is the only way they know how to interact with others, especially those who are 'different'.
- Possibly other reasons but most of those are the basis on which other reasons are born from.