early 15c., "company of soldiers, band of warriors," from Middle French cohorte (14c.) and directly from Latin cohortem (nominative cohors) "enclosure," with meaning extended to "infantry company" in the Roman army through the notion of "enclosed group, retinue;" from assimilated form of com "with" (see co-) + a root akin to hortus "garden," from PIE *ghr-ti-, from PIE root *gher- (1) "to grasp, enclose."
Sense of "accomplice" is first recorded 1952, American English, from meaning "group united in common cause" (1719). In demographics, "group of persons having a common statistical characteristic" (originally being born in the same year), 1944.