The caste system was one way, but it was just one of the many ways throughout the world. Every civilization had its oppression, so understand the caste system wasn't this awfully horrible thing, it was common practice in the world at the time.
Those three actually came out of orderly societies. The societies they came out of were governed by kings who did a good job of keeping the peace. Each of them went on to advocate orderly societies, and helped to keep order in society, but none of them created orderly societies.
A quote from the Dhammapada goes:
"The adulterer will receive misfortune from the king."
The meaning is that the adulterer will be brought to trial and beheaded.
I know in early China, the orderly societies was due to the development of an irrigation system 5000 year ago, which brought on a very bureaucratic taxing system.
For the bureaucracy to work, change was limited. Therefore, if you were born a farmer, you and your sons became farmer and dies a farmer.
If you was a farmer, merchant, whatever, you could not change your status or profession.
This culture spread.
I cannot comment about the others.
Lack of change was forced onto the people, but religion (Buddhism) institutionalized it.
For Buddhism: by purifying one owns mind, speech and action and cultivating morality and wisdom. It's cultivation from its very root, from ones own understanding and effort, not by imposing any punishment or reward.