We can use if when we talk about present & future imaginary situations. When you talk about an unreal or improbable situation in the present or future, we use if + past verb, would/could + present verb. Could suggests one possibility among others I am imagining, an would suggests one particular situation or dream. Look at these examples:
If I won the lottery, I could buy a yacht. I imagine a yacht as one of the things I could possibly buy.
If I won the lottery, I would buy a yacht. I am certain that I a yacht is the thing I would buy and I am not imagining buying other things.
Here are a few more examples:
If I knew her name, I would tell you.
If I were* an animal, I would be a dog.
*Note that after if, we use were, not was, so we don’t say “If I was an animal ~”
We can also use if when we talk about past imaginary situations. When you talk about an unreal or improbable situation in the past, we use if + had + pp verb, would/could + have + pp verb. We often use this grammar when we have a regret about the past or we wish that the past situation had been different.
If I had known her name, I would have told you
If I had won the lottery, I would have bought a yacht.
If I had married her when I had the chance, I would have been happy.
If I had known about the exam, I would have studied.