Kind of a sandwich approach. Flavor first in the broadest sense, like “I want to make a pirate adventure” or “I want a one-shot set in a sewer,” or “this encounter needs to introduce the werewolf theme of this adventure.”
Then, tinker with the mechanics until the math works, since that’s the part that needs the most direct attention.
Then, given whatever mechanics I’ve come up with, go back to the aesthetics and flavor and figure out how it works. If I decided an enemy is ranged, how does it fight at range? Is it magical, or throwing things, or has a weapon?
I usually find some mechanic I want to experiment with or explore then build everything around it. Like finding a feat that sounds cool, or a subclass ability that would be fun to try. I find it difficult to pay attention if I'm playing something simple where I just walk up and hit things with the same attack time and time again, no matter how much I like roleplaying the character. But if I find a cool ability I'll always be looking for new ways to use it and be a more active player in the game.
Plus it gives me a good place to start fleshing out the flavour by justifying why they would have that ability and what it would look like.
I tend to think of a class that might fit the game I want to play, usually magic user, or a subclass that sound afun, so guess mechanics first. Then It used to be that I would choose race to fit that mechanically, but with the relax of the ability score 2,1 I then move on to back story. What sort of story do I want to tell I then pick a race and background to fit what sort background and personality I want my charecter to have. I find the background shapes the now, so are they shy due to past treatment or are they extrovert hero that travels with tales of daring do????
When I roll up a character for a game with a starting situation I have little influence over I start with what narrative impact I want to do. From what I know of the campaign whete I want to drive it. After that how I want to accomplish that, very much including things such as party role/niche and class. Backstory is generally something that comes last when I try and figure out why the character wants to do those things.
When I do have influence over the starting situation mechanical considerations comes earlier. I can mold the campain to a character idea rather than fitting a character into a campaign.