The word is recorded in English since 1634, originally for a young son, identical to the French, which is itself derived from the Gascon Occitan (spoken in Gascony in southwest France) capdet "captain, chief", in turn from the Late Latin capitellum, the diminutive of Latin caput "head" (hence also chief).
Younger sons from Gascon families apparently were commonly sent to the French court to serve as officers; as a rule non-heirs from the European nobility sought careers in the military or the clergy.
For the status as such, the noun cadency exists, as in the heraldic term mark of cadency for a feature which distinguishes a cadet son's coat of arms from the father's which is passed on unaltered only to the (usually firstborn) heir.
Military has been the traditional career choice of the nobility throughout the centuries, and it has been customary that the firstborn son has inherited the title, lands and possessions, while the younger sons of a noble family went to the military, often to be trained as officers. Hence the meaning "cadet branch" for a junior branch of a family and the term "cadet" for an officer trainee.