Further confirmation that you have not tried to reason with 2 year olds.
Hitting children for discipline is a touchy subject because without a proper motivation behind it, it becomes very inhuman. However, sometimes a child doesn't have a large enough sense of the world to be rational.
For instance, "don't stray very far from me" is a very reasonable command to give to a child because of safety concerns. However, what does a child know about kidnappers, careless drivers, or even the feeling of being lost? The child has to have some experience of these things (not direct, could be through stories, etc) in order to be able to reason why parents give that command. Because you don't have 3 years to explain to the child about the world, you have to have a more direct way of making them obey, and it is hard to think of a better way. Most of the ones you can think of involve some form of pain for the child because humans respond the most to pain first (and reasoning as an afterthought). The non-pain alternatives include letting your child do whatever they want to and take the consequences themselves, spending a lot of time enlarging their sense of the world, or making sure they understand that you mean to do good for them. Granted, nothing is perfect in parenting, and you really have to work with what you're given - that said, if your child won't listen to something that affects their wellbeing, you need to give them a reason to listen.
Discipline is also only a part of parenting. You need to give them love, praise, and someone to look up to. Children dislike their parents when discipline is the only thing they remember when growing up. I want my kids to remember me when growing up, not as a family figurehead, but as a role model for them to grow into or beyond.