There have been several attempts to make battery swapping for cars a thing. This includes Tesla's attempt and another company that went bankrupt. For some reason, it does not seem to work out and they all stop trying it.
This is something that governments could solve. Commission a decent swappable battery form-factor and offer tax rebates & incentives to both buyers of compatible vehicles (thus incentivizes manufacturers to make those vehicles) as well as gas stations to adopt the system.
It doesn't have to be perfect performance-wise, if battery swaps take 5 minutes and every gas station supports it, it'll still be good even if the effective range of such battery is half of a custom proprietary one's.