It's a solution to a collective action problem. Amazon has offered a prisoner's dilemma to cities, and it's extremely hard to avoid someone defecting. By making it illegal to defect, everyone benefits, except Amazon (in this case).
e.g. imagine no one had offered any incentive to Amazon. They almost certainly would have ended up in NYC and Washington D.C. anyway, but the taxpayers in those locations would be saved footing the bill for their arrival and taxpayers elsewhere would be saved footing the bill for coming up with proposals, which only existed as leverage for Amazon in getting a better deal elsewhere. Likwise competitors with Amazon would not have to contend with a rival who is getting government subsidies. Overall the free market actually benefits from this intervention.