Why and how does the environment affect the formation of the type of nervous system?

The type of the nervous system is inherited from the parents, the environment affects only the development of various aspects of the already established type. An important role in this is played by the social environment and the upbringing of a child, for example, choleric, with proper upbringing, he will appear to be a balanced and calm person, and a phlegmatic person who has grown up in an environment where there are constant conflicts can also exhibit a high level of behavioral activity. Also, important factors of personality formation include education and the level of intelligence. The smarter the person, the more calm and balanced he is, as a rule.
In what family a person grows, what behavioral examples he sees, how he is brought up, in what collective he studies, works, what he sees around him. All of this, taken together and separately, forms certain behavioral forms in a person. And this is no longer an inborn type of nervous system, but some new acquired traits.
So, the type of higher nervous activity must be considered as a result of the interaction of the innate characteristics of nervous activity and the influence of those external conditions under which a person grew and was brought up. Proper parenting can significantly improve typological properties.

Remember: The process of learning a person lasts a lifetime. The value of the same knowledge for different people may be different, it is determined by their individual characteristics and needs. Therefore, knowledge is always needed at any age and position.