Comparing one revenue line to total net profit is a category error: the numerator and denominator measure different things.
In FY2024, Costco did $249.6B in net sales and collected $4.8B in membership fees. Gross margin on product sales was about $25B. That $25B is 5x the membership fee revenue. So, even if you consider membership fees as being free money, membership fees are only 16% of gross margin.
Moreover, without those product sales, the membership would be worth zero and no one would buy it.