Is it correct to answer if it was or were with “would have”?
If I was rich, I would have bought a car.
Or should it be only would?
If I was rich, I would buy a car.
If the former, why?
To talk about a counterfactual in the past, you usually use the past perfect in the subordinate clause, then the conditional perfect in the main clause:
To talk about an alternative present or a hypothetical future, you use the simple past in the subordinate clause, then the conditional in the main clause:
Some speakers prefer the "were" form here (which can replace "was" when a hypothetical is being discussed):
However, you could also combine the hypothetical wealth with a perfect verb:
Here the sense is that you would have already bought it, possibly some time ago, not simply that would be about to buy it.
Best to go back to the "was" and change it to "were" to match the tense of the the first example. The second sentence is probably fine with either "was" or "were."
"If I was rich I would have bought a car" means that if the speaker was rich, they would have bought a car; that is, it would be in the past.
In "If I was rich I would buy a car", the speaker means that, in a hypothetical situation where they gained a lot of money, they would buy a car.
Generally, in the first situation someone, the speaker may be trying to do that thing, while in the second the speaker is merely pondering what he/she would buy if they had sufficient money.