Walmart and Target are among the retailers that have turned their brick-and-mortar locations into assets after e-commerce threatened to make stores a liability.