The problem was with Cain himself. Instead of getting angry he could have repented and done the right thing. This was a problem that was easy to solve. But Cain found it easier to blame others. This murderous attitude is not so rare.
Anger is a choice, as well as a habit.
It is a learned reaction to frustration, in which you behave in ways that you would rather not. Cain is Warned that he is flirting with danger God warns Cain. He sees the destructiveness of Cain's attitude. This was a pivotal moment in Cain's life. His soul hung in the balance.