TOKYO—Cars already know how to park themselves, warn drowsy drivers, steer back into the right lanes, and propose map routes to destinations. The cars Mazda has in the works for next year in Japan know when drivers have a stroke or heart attack. By 2025, the cars will even know when drivers are about to…