One tech giant strung dozens of North American cities through a circus-like contest that led mayors and governors to desperately pitch their regions—and offer huge sums of public money—in hopes of landing a gleaming new corporate campus. The other swept in quietly before making its big move.