Setting can affect characters in literature in any number of ways. They can create conflict for the character, they can be said to form the character, and they can influence the character's actions. Let's look at a few examples.
In a setting of war, there are many examples of how conflict is created for the character. In The Kite Runner, while there is a great deal of conflict between the characters, the setting itself often creates conflict for them as well. Fairly early in the book, Amir and his father must flee Afghanistan. When Amir returns to Afghanistan, it is still in a state of war, creating conflict and danger for Amir and Sohrab. In Anne Frank: The Diary of a Young Girl, which takes place in Europe during World War II, the tension amongst the characters and the dangers to them are the result of this particular setting.
Some settings can be said to form characters, just as in real life our own characters are formed by our settings. In The Giver, with few exceptions, the characters of the community are formed by their setting, a time and place removed from the rest of the world, insulated from all influences other than the rulers of the community. Their setting has made them into a group of compliant, almost robotic beings. On the other hand, in another isolated setting, the characters in The Twenty-One Balloons become wonderfully inventive.
A setting can strongly influence the actions of a character. In The Kite Runner, the difficulties that Baba has in the new world humble him. He was accustomed to being at the top of the heap in Afghanistan, and now he is an immigrant, at the bottom of the heap. This causes him to change in many ways, to work harder, to dirty his hands as he never would have dreamed of doing in Afghanistan, and he also seems to gain some empathy, allowing him to be a better father to Amir. Had he remained in his original setting, he is unlikely to have grown as a character.
It is interesting to speculate about how many writers begin with setting and how many begin with characters. Either way, setting and character must go hand in hand in a way that provides a conflict, a consistency, or a catalyst.