Let's back up a step to casting. Once I've chosen the protagonist(s), the next step is assembling their Scooby Gang. Each member represents an archetype (and when you're writing a series where all the characters evolve, remembering the archetype will prevent you from evolving the characters into the same person with a different face). Each archetype is meant to push or pull the protagonist through the story via actions and conversations.
Now it's time to assign gender to those archetypes. Making those choices comes down to the protagonist, their personality, and their history/backstory/all the stuff that happened before the book starts. Take authority figures: who is the protag most likely to respect, and who is the protag most likely to resent? The "why" behind those answers defines gender, age, sexuality, race, religion, etc. The process repeats for each archetype.
With the gang decided, I go through a similar process for the antagonist(s), but this time the plot plays a heavy role in determining what type of Who that will be.
The first round of casting done, I look at team-composition balance. If the only female in my book is my protag, then I need to make some tweaks. (I also need to give my protag a personality adjustment.) Some stories will have casts that are more dude-centric, some more female, those decisions come down to plot. Since I write series, I do try to alternate. Admittedly, I haven't written a story that is nonbinary centric yet, which is something I should change.
Ah, but the question of the week is "how do you write the genders differently?" It all goes back to the characters' relationship to the protagonist. See, it's not about writing the genders differently, it's about writing the characters so they're unique.
In my IMMORTAL SPY series, I have one character who is a body thief, Drew. Drew is a nonbinary creation by an Under World goddess. In the lands of the living, Drew is genderfluid in a rather literal sense; Drew's gender (and species) changes based on the body they occupy. While Drew changes bodies more than once during a book, there is never any doubt that the entity inside that body is Drew. It's speech patterns, phrasing, impulsive actions, fierce loyalty to the protagonist, and a little too much glee in inappropriate moments. Small details. Personal tells. Individual tics.
Remember: Our genders don't make us who we are, our character does. Same holds true for the characters we create.