There is no one clear solution, but there are lots of factors that have proven to be linked to anxiety, depression, ADHD, autism etc. Not causing them, but worsening symptoms.
Just to link some examples regarding food: https://scienceinsights.org/what-vitamins-are-good-for-anxiety-and-depression/
https://www.healthline.com/health/mental-health/how-sugar-harms-mental-health
https://www.adhdcentre.co.uk/what-is-the-relationship-between-adhd-and-nutrition-how-diet-impacts-your-childs-behaviour-and-focus/
https://neurolaunch.com/diet-autism/
There is tonnes of research out there about how our lifestyles effect us as humans. Some of it quite unexpected - like led bulbs effecting metabolisms due to lack of red light, or household chores decreasing dementia risk.
As to why it's not always highlighted by medical professionals - I'm just guessing, but maybe it's partially they're not specialists in nutrition, partially they don't think it's realistic to ask patients to change their whole lifestyles, partially they do mention them as factors but then leave it up to the patients to decide what to implement.
For example, I think every parent has heard that sugar can worsen ADHD symptoms and that it's bad for us in general. Lots of parents still feed their kids sugar. We live in the modern world and it would be very hard to tell your child they're not allowed what all their friends are eating.
That's what I mean by my first post saying that I put a lot down to modern lifestyles. It's almost impossible to opt out of ultra processed food (just look at school canteens), smartphones, depressing world news bombarding you, a less cohesive community network, etc etc.
To be honest I find it strange that you think our surroundings don't have an effect on our health and wellbeing.