late 14c., matris, matrice, "uterus, womb," from Old French matrice "womb, uterus" and directly from Latin mātrix (genitive mātricis) "pregnant animal," in Late Latin "womb," also "source, origin," from māter (genitive mātris) "mother" (see mother (n.1)).
The many figurative and technical senses are from the notion of "that which encloses or gives origin to" something. The general sense of "place or medium where something is developed" is recorded by 1550s; meaning "mould in which something is cast or shaped" is by 1620s; sense of "embedding or enclosing mass" is by 1640s.
The mathematical sense of "a rectangular array of quantities (usually square)" is because it is considered as a set of components into which quantities can be set. The logical sense of "array of possible combinations of truth-values" is attested by 1914. As a verb, in television broadcasting, from 1951.