In addition to Kate Gregory's fantastic answer concerning the practicalities of hiring internationally for the perceived benefit of lower short-term costs (as seems to be the intention of the question, not simply "locally", e.g. a company in Silicon Valley hiring someone in a different part of the country where the cost of living is much lower), I'd like to offer an additional motivation: ethics. Be it "patriotism", camaraderie, or the general sense of duty to one's craft, society and locality and that enabled you to ascend to the position of being able to hire others in the first place.
This is especially true when it comes to hiring junior and mid-level developers (some of us once were one!) From a personal standpoint, my commitment to enabling someone's growth and development is far greater than my commitment to the abstract principle of unfettered movement of capital. From a business standpoint, I know that the increased productivity and low turnover repays in spades over the medium- and long-term. In addition to creating positive relationships that fan out over time.
Hiring someone, locally or not, is an investment, and again echoing Kate, the difference in salary would have to be large for it to be worth considering. And if it is-- what are the externalities? And when we're in a crunch, would I feel as comfortable asking someone making pennies on the dollar to stay late or give up a weekend? And if not, how is that fair to my local employees?
As others have pointed out, the truly committed to the neoliberal way set up satellite offices in Costa Rica, Poland, etc. to exploit local markets directly. Earlier in my career I was part of a company that did this due to holding company mandate, and though many of the developers were talented, the work suffered because everyone hated the process, which is intended to reduce cost first and foremost. There are also many shops in South America or Eastern Europe that retain project managers in their target market to give the perception of cost effectiveness & local presence, but in reality people are where they are, subject to all the above and the daily friction quickly adds up. All the while those are more dollars leaving your community.
In summary: not only is it more often than not a poor business decision, but some may also find it to be a question of personal ethics as well.
why would the salaries be the same?
Market forces. As an employer in SV, why would I pay a remote Swede more than a remote Pole if they do the same work, just because the Swede chose an expensive place to live? It's his choice/problem. I mean, I could get away with paying the Pole less at first, but then I'd choose the Pole, and eventually Polish remote dev salaries would catch up due to the market forces. (This also applies to local vs remote unless there is an intrinsic motivation to hire locally)