Reasoning varies. For some it is a perception that they should and will help their immediately proximate community by buying from them rather than from others. For others the higher certainty that locally produced goods meet human rights and environmental standards means buying locally is an acceptable proxy for other ethical ends.
For a growing number local consumption is considered ethical because avoiding unnecessary transport from afar presumably means the avoidance of unnecessary greenhouse gas emissions. That's an admirable concern, but an incorrect presumption.
Economic geographer Pierre Desrochers and consultant Hiroko Shimizu have written a neat policy primer called Yes: We have no Bananas, a critique of the food miles perspective (It's nicely summarised by this article from the appropriately titled ReasonOnline). In it they find that the proportion of "farm to plate" emissions that come from air transport are minimal. A comprehensive UK study found that air transport contributed just 1.8% of life cycle emissions, trucking within the UK 31% and the emissions of the shopper travelling to pick up the products was 48%.
Best case scenario then, a decision to buy locally is saving you 1.8% of emissions. You are still making a saving so that's not wholly destructive of the food miles argument. But this is. Comparative advantage is the idea that some places produce some things better than others. You can grow bananas in Iceland, apparently, but because of climate, soil cost of labour and capital, you'd be a damn sight better to grow them in Costa Rica instead.
The economic benefits of growing in a more productive locus often correspond to environmental benefits too:
For example, the 2005 DEFRA study found that British tomato growers emit 2.4 metric tons of carbon dioxide for each ton of tomatoes grown compared to 0.6 tons of carbon dioxide for each ton of Spanish tomatoes. The difference is British tomatoes are produced in heated greenhouses. Another study found that cold storage of British apples produced more carbon dioxide than shipping New Zealand apples by sea to London. In addition, U.K. dairy farmers use twice as much energy to produce a metric ton of milk solids than do New Zealand farmers.
Other researchers have determined that Kenyan cut rose growers emit 6 metric tons of carbon dioxide per 12,000 roses compared to the 35 tons of carbon dioxide omitted by their Dutch competitors. Kenyan roses grow in sunny fields whereas Dutch roses grow in heated greenhouses.
The net result is that the consumer who really cares about the environmental effects of their consumption needs to make their choices on a case by case basis. Food miles are not a indicator of environmental outcome. Therefore, neither are they a sustainable argument for discriminating between local and foreign goods.