'But not many organisations do so to damage a rival by attacking one of its rising lines of business. Does Walmart really have it in for Amazon?'
Is that true? It seems like the same strategy Google followed with Android. They didn't have a lengthy history of open-sourcing projects of this scale before it became necessary to claw back mind and marketshare from iOS.
Also see Openstack.
What Warren Buffett calls a company's moat is the value it has that allows it to charge a premium over the long term and make profit. Amazon are a big threat to the moat of many firms including Walmart and a host of tech providers. Eroding Amazon's moat is one part of their effort to neutralise that threat.