Total cost of ownership of a car will likely be higher (especially if it’s a nicer car, and you use it in places where you need to pay for parking), but public transit and cars are not exactly equivalent products.
Public transit can be very cheap and convenient for some use cases: for example, if you live close to a stop, your destination is close to a stop, there is straight transit line between the two places, it runs frequently and has few stops on the way, and you usually travel by yourself. If all of the above is satisfied, it will likely to be more cost effective and similarly convenient to use public transit. However, for many other standard use cases, public transit is by nature very inconvenient compared to cars: for example, if you visit grandma with your small kids on a regular basis, grandma lives in a small town, getting to which on public transit from your home requires 2 transfers, and is only reasonably possible twice a day at very particular times. In that scenario, which, by the way, is (in some form) extremely common for most people who aren’t single professionals living in big city, public transit is just a non starter, even in Germany.
Since the latter scenario is, as I point out, rather common, most people own a car anyway. At that point, you’re already paying the total cost of ownership just to use it on routes where public transit is extremely inconvenient. This changes your calculation on routes where public transit actually is pretty convenient: sure, public transit on that route might win with total cost ownership of the car, but once you already have a car, fixed costs are already sunk, so public transit is now competing with marginal costs, and it might very well then lose.
For this reason, even in countries with good public transit, it is largely a domain of students, young singles, and retirees, and working people with families overwhelmingly own and use cars.
I also find it hard to believe that a bus / train pass costs as much as car ownership fwiw