Lawrence Kohlberg developed a theory that explains how people understand right and wrong according to their age and maturity. He said that people progress through six stages of moral development.
The first three stages happen when people are young and focus on pleasing others and avoiding punishment. In the first stage (Preconventional Morality) children learn that it's wrong to do something bad because they might get punished. In the second stage (Conventional Morality) children learn to follow rules to please parents and teachers. In the third stage (Postconventional Morality) people start to figure out for themselves what is right and wrong.
The last three stages happen when people are older and begin to think about more complex issues. For example, in the fourth stage (Social Contract and Individual Rights) people learn that it's ok to disobey rules if they think the law is actually wrong. In the fifth stage (Social System Morality) people think about how their behavior affects other people and society as a whole. In the sixth and final stage (Universal Principles of Morality) people think about an ideal world and try to make decisions based on what will make it better for everyone.