This question is matching the king of in-store or traditional retail vs. the king of online retail. They both dominate their respective territories. Your question is specific to Amazon competing with Walmart.
In online retail, Amazon is winning and it is Walmart that is trying to compete with Amazon. So far Walmart is doing well with their base of customers in selling products online for convenience, but have not been successful in gaining customers outside their retail base. This limited online sales success is unlikely to change despite Walmart spending mountains of cash in upgrading their online infrastructure. Amazon is just too far ahead and continues to pour their own seemingly inexhaustible cash to keep it this way.
In the in-store or traditional retail space, it remains to be seen if Amazon even wants to compete with Walmart or any other retailer. Why would they? It cost more to establish and run stores, harder to manage thousands of locations of inventory and is just less profitable with higher risk. Instead, Amazon is going to invest in technology that retailers will buy/license from them to run their stores more profitably by allowing customers to shop and buy products in-store directly and eliminate the need to go through checkout. While this is not good for the tens of thousands of check-out clerks working in retail stores today, it will make the process of shopping more convenient for customers and will reduce costs for the retailers. This will in-turn make retailers more profitable and probably reduce the cost of products at retail stores.
So it is highly unlikely that Amazon will ever choose to compete directly with Walmart. Instead, they will supply tools and technologies to make in-store shopping a better experience.
, E-Commerce, B2B & Retail Sales & Marketing Expert