Why does God get mad a people in the Bible for things they do before he even creates and/or announces the law?
God writes his moral law (but not his ritual law) into every human heart. We call it the conscience. That’s why Adam and Eve felt the need to cover themselves and hide from God, and why Cain tried to make excuses after he killed Abel. Because they knew they had violated the law written into their hearts.
As Mike said. cf. Romans 2:14-15
Only the Mosaic law was not given.
God communicated actively with mankind.
God spoke with Cain (Genesis 4:6-15).
Enoch ‘walked with God’ (Genesis 5:23).
Also, there seems to be at least an oral tradition. Genesis 5:29 has Lamech stating that the ground has been cursed by God. Genesis 4:23 has Lamech speaking about what his forefather Cain had done. If he knows these things, it stands to reason that he knows why they are and also has some inkling of how he should behave.
So, men were not completely in the dark.
Plus, there is the self-evident natural law which is discoverable by any man using his reason.
I don’t think that conscience is the correct term to refer to the moral law written on our hearts. I’m not even sure that the moral law is written on our hearts yet. I think that where this is spoken of in the Bible, it is spoken of as something which will happen at the end of time to those who will live in the New Jerusalem (Book of Revelations).
A conscience can be properly or improperly formed. Indeed, it is the duty of Catholic parents to properly form the consciences of their children so that their conscience informs them of right and wrong.
However, there is natural law which is discoverable by human reason alone, without revelation. This is the law which permeates almost every society on earth. i.e. don’t steal, don’t murder, etc.
The natural law is the law that is considered to be written on everyone’s soul. One does not need the be Cathechised to be held responsible for Natural Law sins. Invincible Ignorance is no defense against murder, or adultery. In this sense it informs our conscience.
If that is true, why did God have to give laws forbidding these things to mankind?
One reason was to provide for the corresponding punishment. For instance, the natural law says, “You shall not murder,” but the Mosaic Law codifies both the law and the sentence: “You shall not murder … whoever commits murder shall be stoned.” “You shall not steal … whoever steals must make restitution threefold.” And so forth. (And no, those are not meant to be quotes but just illustrations).
Another reason, as Aquinas points out, is to reinforce the natural law, since human reason can be weak and self-justificatory. However, the knowledge of natural law by itself is still enough to condemn wrongdoing.