It happens more-or-less naturally. Most legumes have a seed structure with two large cotyledons that serve as storage reserves for the developing embryo, which is nestled between them at one edge of the whole structure. This is easily visible in the peanut (which is botanically a legume and not a true nut):
The outer pod that splits open serves to protect the seeds. Each of the "nuts" inside is a whole seed. On the left is one with the outer coat intact (very thin and papery for peanuts, but often substantially tougher for other beans) and on the right is a split nut. This is a single cotyledon or "lobe" with the small embryo (which looks almost like a separate seed) visible at its left tip.
If you look closely, other culinary legumes share this same structure; even lentils have a tiny seed visible at one edge. The lobes meet against each other with flat edges and will separate easily once the legume is dried. They can still be held together by the outer skin or coat, which varies in thickness; beans tend to have thicker coats, lentils much thinner ones. Once the coat is removed by peeling or rubbing, the dried legume will separate easily into halves with additional quick rubbing or tumbling. This in turn increases the surface area and allows the legume to cook more quickly.