Most batteries are modular but some car makers (Tesla) seemingly don't allow repairs or servicing and want to sell a new battery. There are major issues concerning right to repair in the US going on, and also within the EU, and it should be possible for someone qualified (and there are many companies starting that work on batteries) to repair or recondition batteries, as well as safely swap out a battery. This sort of thing needs to be sorted in courts around the world, or else people will be ripped off for fixing any battery issues (however rare) as EVs age.
The cost of batteries means that (from the last report I saw but can't cite here) it's around $3500 for a battery from one of the major manufacturers - an absolutely staggering fall and I think they're likely cheaper still by now. I'm not sure what size capacity they averaged that for, but likely bigger than the batteries coming in the small B-segment cars (thus, they're going to be even cheaper). Once you've added on the relevant costs, that's still not cheap but neither is it the £20-30k or £50k figure that some people seem to make up quote.
Nissan in Japan will sell a new battery for an old Leaf for around £3000, but how many people with an old car buy brand new parts? Once my cars were old enough, they were repaired by independent mechanics using salvaged parts. The same will apply for batteries for most people unlucky enough to need a replacement (or not even necessarily unlucky as maybe they used the car so heavily that they have probably been saving a fortune for years by that point).
As I've said before, I'd always feel safer buying an old EV over an old ICE car given the hidden surprises it might have. An EV is a pretty simple design and should not only be more reliable in the first place, but cheaper to fix. Bar the battery itself (and maybe the BMS), it should be easier for people to fix too. Again, there will be issues with part pairing and other methods put in place to stop anyone being able to work on a vehicle they supposedly own, but that's for Governments to regulate. Those same issues apply to ICE cars too, and will for everything if we allow it.