In my first completed novel, there was a side character who I wrote as transgender, even though in the story her identity is never brought up. She was my favorite character, as well as all the beta reader's, but I didn't think much of it. In the same novel, I tried writing a female lead instead of a male lead for the first time, and things just clicked. I was able to get inside the main character's headspace so much more easily than with any character I had ever written.
I figured out I was trans several months after finishing the novel, for unrelated reasons. When I go back to the novel now, the whole thing reads as a massive struggle with gender identity. The main character is obsessive about being able to hide her powers and be seen as "normal," she has an enormous amount of self-loathing and internalized shame, and only after trusting others and letting them in is she able to begin to accept herself. It's legitimately a little hard for me to read, because it feels both like a novel and a frank, unflinching portrait of me when I was figuring myself out. On one hand, it's affirming knowing how much happier I am now, but on the other, wow.
Compare and contrast to now, where I end up writing most characters as LGBT+ without even thinking about it.