Most of the European nations with F-35 currently either joined the program from the beginning decades ago, or want to participate in nuclear deterrent and have no other option (unless France decides to share their nukes, but that hasn't happened yet, and you can bet they'll want you to buy Rafale for the privilege if they do), or want stealth capabilities which nobody else can offer right now, or want greater compatibility with the US munitions stockpile which is vastly larger than what Europe has available... etc.
Jets take a long time to develop, the time for Europe to get serious about "strategic autonomy" in that respect was 2 decades ago. That didn't happen, so now the F-35 is the only option if they want the capability to penetrate Russian ground-based air defenses and consistently beat the Su-57 (cough all 8 of them, but it's possible they scale up eventually).
The Gripen's problem is that it is expensive for a light fighter. The other problem is that uses an American engine and US can control export. There aren't many countries that can't buy F-35 but can buy Gripen. Brazil is the big one.
The French Rafale is having more success because it isn't export limited. It is better than Gripen and same price.
In terms of operating costs, yes the Rafale is cheaper, mostly because it's not stealth.
The fact that France is spending their money in France helps make up the difference - for France. But if you aren't France, the F-35 is a good deal.