The car manufacturers do it by stopping selling parts. That's OK when it's easy for a 3rd party to fill in the gaps but I do wonder how this will pan out with modern EV's.
Given the strength of the second-hand car market and aftermarket repairs, this will most likely turn into a prolonged legal war. Not sure which side will win, but I'm hoping it won't be the car manufacturers.
Yeah, parts don't work for that reason. But cars are increasingly dependent on software, and they can use that. John Deere and farmers wanting but unable to repair their own tractors have been mentioned on HN a couple of times.