Let’s mince some words with a couple of arbitrary definitions for the sake of having a discussion.
Flat characters, to me, are ones that are built as a list of bullet points, and you can see right though them. The character is X, Y, and Z, and so they do things that are obviously connected to those things.
It’s a great starting place, but we can get ourselves into all kinds of trouble. Another way you could look at “flat” is “stereotyped”. They’re not exactly the same, but within the category of person that this character is—the category of XYZ—if they act squarely in the center of what you’d expect, then they’re not interesting.
Sometimes the mere exploration of XYZ is enough of a literary task to make the character truly interesting, but don’t rely on this justification. Are you absolutely convinced your XYZ is so unique that it demands a book be written about it? If so, fantastic. If you’re kind of waffling as you decide, then the answer might just be no.
So start asking yourself How your character is. This requires you to understand their internal struggles, not just because of XYZ, but because they are a rational-emotional being. What things do they say or do that might at first contradict this XYZ formula? We all have them. We justify things to ourselves, we synthesize explanations for our behavior to others when they call us on contradicting our core beliefs. Some things get us mad while the person next to us goes unfazed. Some things bring some of us to tears, and others not.
These things are in motion at all times. I’m a black box and you can’t always know how I’ll be just because I am XYZ.
Allow yourself to create diverse characters. Try making two characters that are both XYZ, and yet are fundamentally different people in the way they think or act.