People learn best from having consequences to their actions. A very young child generally lacks the empathy required to put themselves into another person's position, to consider the impact of their actions on someone else, to not do something that they want to do because of how it will affect someone else.
That's too complex for a new mind! No. They work on see toy - want toy - bash you - got toy 
They require an association to override that, something they can understand. see toy - want toy - bash you - sit on step
You work on teaching them to consider others. But it's a long process. you can't rely on them being able to do that at 2 yrs old, 3 yrs old, hell, when they get to 4 it's still hit and miss!
You need to make them behave nicely to others before they understand why they should behave nicely to others!
You can sit a 2 yr old down and explain that they hurt someone and made them sad until you're blue in the face, they'll still bash that child over the head next time they want that Big Yellow Teapot, because they won't remember to consider the other person's feelings, they won't go oh, I really want to play with that, but I remember last week I hit thomas and mum sat down with me and explained that I had made him cry. That was sad. If I do that again, he will be sad again. It's important to me that I don't make Thomas sad, so I won't take the teapot, I'll go play with this train instead.
But they WILL think hitting = step (or whatever)
And then, of course, there is the point that for most people of all ages, what modifies their behaviour is more to do with what's likely to happen to them than any genuine concern for the other person and desire to put the other person's needs or wishes before their own. We don't like to admit that, but I think it's true.
eg - I say I don't steal because it's morally wrong. This may also be true, but I don't steal because I don't want to go to prison! If that was assuredly not a consequence, I'd probably have a brand new car right now 
Someone is rude to me in the supermarket. I don't punch them in the face. I say this is because I am opposed to violence/refuse to sink to their level. In reality, it's just as likely to be because I don't want a punch back, or I don't want to get arrested.