This is something that I learnt with practical observation. I used to wonder about this during my young age. Especially during my school days, I used to observe a group of students who always stay together and each one in that gang will study well and get good marks. I now think if it was like they became friends just because they all study well but that was not the case. During young age we don't know what is good and what is bad.
Most of the learning comes from people who are near us. We learn many things from parents and we learn many things from our friends and then we learn from our classmates and as we grow up we tend to learn things on our own. There is also a famous proverb that says "Tell me about your friends and I will tell you what person you are." The proverb is so true. If we are good in character it is purely because we stick with good people. If we stick around bad things we will obviously turn into someone with bad intentions.
There is also another saying that "Every child in this world is born innocent. The way they grow up defines their character." If there are good opprotunities around the child and if there are good and wise people around someone their thoughts and actions will obviously turn good unless in extreme case where an extremely bad child would polute the entire crowd by introducing bad things that they learned somewhere from outside.
If we would like to be wise and knowledgeable in life, it is important that we stick with people who are wise or at least someone who have the intention to be wise. If we don't get such opportunities we should at least try and see that we are not polluted by people who don't have that thirst. Gradually if our thirst towards knowledge is high our life itself will drive us in that direction and give us opportunities to pursue our exploration and become wise.
It is commonly said that if we will have to become rich, we have to stick with people who are already rich. That is how we can learn many things from them and understand how we can also pursue that path. That is one of the reasons why people are attracted to Warren Buffet speech and quotes. People are attracted to them because people admire they way they think and try to adopt that. Same is applicable with wise people as well. If we observe them and understand how they seek their knowledge, that will be a great addition for us as well.