As you've noted in your question, the country matters if your story is about events or culture peculiar to that country. Someone mentioned Dr Zhivago, which is a story about the Russian Revolution. It would have made no sense to tell that same story but say it happened in Canada.
In many stories, the country isn't all that important. A murder mystery or a love story could be set in any country that has ever existed, as -- to the best of my knowledge, anyway -- people everywhere commit murders and people everywhere fall in love. Still, the country would affect the story.
In an important sense, the setting always matters. A love story set in a country in which marriages are normally arranged by the young people's families would be rather different from one set in a country where young people choose their own spouses. I'm sure every country has unique cultural traits that would affect the flow of the story.
I think most writers set a story in their own country when there is no good reason to set it somewhere else for the simple reason that they know their own country and so they don't have to worry about making mistakes on the background. I wouldn't just pick a random country to set a story in without knowing a lot about that country. You'd be likely to make all sorts of mistakes that anyone who DOES know the country would quickly spot. People might let you off on the details. Like if you say that the hero went to a bookstore in the town of Foobar and a reader who knows the place knows that there are no bookstores in that town, he might skim over it on the reasoning that it was important to the plot that the hero visit a bookstore and so you just invented one. But if you are regularly talking about characters being stuck in traffic jams in a country where in reality few people have cars and the roads are always empty, or if you talk about the king of a country that has no king, or about the blizzards in a tropical country that hasn't had snow in recorded history, etc etc, it's just going to be jarring.
Is there an advantage to setting a story in a different country? Like, if you live in Taiwan and your primary market is Taiwan, do Taiwanese readers tend to prefer books set in their own country, or books set in foreign countries? (I have no idea.) I suspect it depends on the story. With some stories, a foreign setting would be exotic and could add flavor. With others, it would be distracting. Like, when American authors write an adventure story, they almost always set it in a foreign country, because the further from home you are the more of an adventure it is. But when Americans write a crime story, they almost always set it in America, because a foreign setting could make clues more difficult for the reader to interpret and would require additional explanations all over the place.