This is what is commonly known as Two Year Rule or 212(e) which is applicable to few different situations, e.g. if you get a grant from your government for your training or your profession is on your home country's skill list. It's also pretty random and I for example was stamped with the rule but many countries issues "no objection" letters which allow you to waive the requirement. Two year rule does only affect some visa types, such as H1b but not O1 or J1 visas.
Here's more information: http://www.isso.cornell.edu/academicstaff/jwaiver.php