When we speak about the future, we use the present simple after if.
If I had money, I would buy it.
When we speak about the present, we use the past simple after if.
If I had had money, I would have bought it.
When we speak about the past, we use the past perfect after if.
If you are good, I will give you a rope.
If you don’t tie the sheep, it will run away.
If you come at four, I will be happy.
If I had one free hour, I would walk to a fountain.
If the little prince had had such power, he would have been able to watch the sunset many times on the same day.
You can see more examples in the book The Little Prince.