Amazon's infrastructure roll out paid off in the United States because there was little competition. They rushed out infrastructure and cornered the online shopping and delivery market. Walmart and the other big stores had an entirely different business model and their warehouses and infrastructure took time to adjust and catch up, with Amazon still in the lead.
In China, the local competitors already have a significant head start on their infrastructure, and Amazon would be playing catch up in a relatively unfriendly market. It could take them forever to recoup the investment, if they ever did.
Unfortunately, they can't compete without that infrastructure in place, so what else can they do but leave?
China is the biggest eComm market in the world! If there was an opportunity for Amazon to penetrate (regulations being the biggest challenge), Amazon would have totally gone for it.
This is a company why, 5 yrs back, committed $5B to India when eComm there was/still is totally burgeoning.