Why is the mitigation of criminal liability in relation to minors considered a way to prevent crimes?

A minor is not yet mature enough, often does not know the law, repents of his deed, therefore, the punishments are often educational in nature, so that the minor realizes his mistakes and does not allow them in later life.

Remember: The process of learning a person lasts a lifetime. The value of the same knowledge for different people may be different, it is determined by their individual characteristics and needs. Therefore, knowledge is always needed at any age and position.