Mounting competition from Walmart and other big retailers is forcing the online leader to invest more on delivery