There’s no problem; Costco is an intermediary that brings value and so it takes its cut. Why do people buy from Amazon, who is also "just" an intermediary? Because you can buy millions of different products from one single place instead of having to go see each manufacturer where you wouldn’t be able to buy individual items anyway.
This situation is a lot more effective than forcing each manufacturer to develop its own customer-facing business with all the costs and logistics that go with it.
So what's the solution to this problem? In one way I think this could be framed as rent seeking via economies of scale.