Major shifts in the grocery industry are forcing retailers to rethink store networks, as competition and rising costs reshape where Americans shop.