In my wife's case, it is a combination of general talant along with deliberate education and feedback.
Everyone loves her Chinese cooking. But I note that it's actually Chinese/American (not ethnic Cantonese or full-bore Sichuan) and furthermore is customized to my family's tastes.
Two anecdotes on deliberate learning: first, I found initally that the use of ginger was overpowering in most meat stir-fry. I noticed the pattern and discussed it with her, figuring it was a difference in taste calibration. She changed that, and ended up finding a sauce that I like very much.
Second, she wondered how to make something that would go good with family dinner. I suggested using seasoning that matched what I knew the entree would be using (e.g. Majoram). More generally, what would my parents like? Learning Mom's recipies let her know the general palette of flavors.
Now I see that it requires talent as well. How does she know when a recipe is "right" for someone else? It helps to have a hugely broad and varied palette of taste herself. It is good to be able to taste nuances of not-so-spicey food as well as being able to appreciate very spicey things (at a restaurant recently, 10 wasn't high enough and she had the chef go up to 12 instead!).
Given a particular combination of seasonings (and avoiding others) she's learned what it should form as proper chords of flavor, so can come up with something new that still fits.
Without being directly able to work within someone else's flavor box, I think a few things can still go a long way: know the individual basic flavors of that cuisine (e.g. how much majoram is used in Polish sausage), so seasoning "something" can simply use a standard amount of the chosen spice. Avoid particular flavors that are not liked or are hard to use well or are sensed differently (e.g. if a dish doesn't have broccoli in it, you don't have to worry about the sulpher overpowering or changing the underlying notes compared to someone who tastes it as sweet instead).
If you can't make novel works in someone else's "box", then stick with already calibrated and vetted combinations.
Finally, get feedback at critical points. I grew up on very low salt, for example, and she'll ask me to taste when adding salt if she thinks it's the right measurement but still seems unsalted to her.