Economics is a post hoc explanation for how the market works. It's not like somebody came up with the theory of how a market should work and then built one, like you would a computer. Rather, markets existed back in the middle ages before economists did, increased the wealth of its participants, and economists later appeared to explain why that was the case. Nowhere is the prerequisite that this system is the result of logical design.