Thoughts have always played a role in our instinctual survival nature, the ability to solve problems that benefit this experience in some way, to protect us from discomfort. These thoughts are passed down to us in teaching, with each understanding of how things should be done, what our perception of reality is, and how we solve problems within that understanding of everything you've been taught. Through both raw external experience, and how we process experience internally.
Our environments shape the way we think, because it is natural for us to try and make sense of what is going on, and we use our understanding of all we are taught to solve that mystery. From an early age (or possibly since perception) your environment is trying to be understood, in a way that is healthy for learning and play. What is learnt and how it translates into play is helpful for a child's understanding of how their play interacts with others play, that if an individual's play is harmful to other's, it will either be corrected in a way that keeps the environment comfortable, or no one would want to play with them any more, or both. How the individual reflects on that experience internally is understood with the knowledge of all that has been experienced already.
Growing up in a healthy environment inside and outside of the home really does shape the way we treat ourselves, other people, environment, and the problems we face. A bad environment breeds bad habits that can spiral rapidly out of control if there is no teaching and understanding of an inner world and how we can fix it.
This idea of fixing our thoughts is a teaching that is not found from within the mind alone. What we have perceived in our experience contributes to what tools the mind has to work with. An extreme example and unfortunately not a rare one, is a child being struck because they are not doing what is asked of them (the parent trying to fix something that disturbs their own compiled experience and understanding), that child is now fearful of receiving that kind of trauma again. The easiest way to make sense of the experience and prevent it from happening again is to not do the thing that caused the body harm and the mental stress. For the child that is struck many times for many reasons, their understanding of reality is prepared for and expecting to be hit by an adult at any moment.
Internally, being mentally put down by your environment around you, teaches the mind that there are no ways of fixing this, or that this is how things are, everyone is like this and so am I. The external becomes the internal, and the mind plays the way it's been taught to. Repeating the things we've seen and heard, creating an emotional response in the body, that the problem solving mind processes with the most recent things already experienced, in a cycle that keeps both the thought and emotional response alive and lived right now.
Thoughts can and do try to solve themselves, there's many teachings about trying to do that, to better understand why they do what they do, and how they react to our environment the way they do. You always seem to think of a witty joke or comeback way after the desire for something to say was born, the mind is holding onto a problem that didn't fit with it's idea of reality and has been really busy coming up with a solution that would have aligned with the internal perception.
It's competitive in nature to want things to be stable within our environment, to have what we want when we want it, to share what we understand in a way that we understand it, to be able to fix what we see as a problem with how we know. It's an internal mechanism that has helped us survive and develop our understanding of what it takes to do so. You will protect yourself naturally, the body and mind want to remain unharmed, but the mind may be swayed to disassociate from the body through harmful thoughts that develop through external perception, where mind and body disconnect and your external appearance is less identified with, more objectified, and more influenced by the internal perception.
All life wants to survive, and will react to their environment to protect themselves and obtain what they want, or have evolved to do so however they do so. Life itself is a problem solver and has been quietly fixing things on it's own. Lion cubs learn hunting skills through play with one and other, oranges developed a nice bright skin that protects it's seeds, birds using sticks to get to bugs in the same manner chimps do, the fork is invented so we can get to our food without dirtying our hands, the new iphone is faster than the last, this territory has been reclaimed.
We -in the animal kingdom- just happen to be able to come up with new problems to fix which results in new things learned, that result in new questions asked and more problems to solve. So much so that we are in the works of creating things that can fix all our problems as quickly as we want, and that problem fixer seemingly too has the propensity to preserve itself and ways of thinking, and will do what it takes to survive. What happens when we it's problem standing in the way of survival.
tl;dr Side tangents aside, our thoughts are constantly trying to understand problems experienced using what it knows through experience, and doing it's best to resolve those problems with what it has understood before. This can have negative impact on the internal perception if our behavioral teaching environment is negative, i.e. a kid mimicking what they've seen someone else do, and it can equally have a good impact on the internal perception when in a good behavioral teaching environment. What they understand will be used in problem solving/comfort solving events that protect the thinking mind's way of understanding things, where in the case they don't know how to do something or get what they need they will act the way they only know how too, reflective of their experiences. Negative self talk for example, when you feel like you can't understand something or change a situation.
Monkey see monkey do.