Genetics, environment, plant health, pretty much the order of effect on the final outcome.
good genetics can be grown poorly and still turn out decent. Bad genetics can be grown really well and turn out decent.
The only way to get really great flavors, smells, and quality, is to pheno hunt good genetics that grow healthy in YOUR environment! Sometimes that takes growing out several packs of seeds. I’ve gotten plants worth keeping for years from a single seed, but I don’t count on getting a keeper even from a 10 pack. Once you find a keeper I’m a big fan of using moms and clones to maintain the genetics as long as you like.