Taking little room for what it holds. Also an agreement between parties — both are things drawn tight.
Latin compactus, past participle of compingere (to fasten together, join), from com- (together) + pangere (to fix, drive in); a thing drawn tightly together, whether a small object or an agreement binding two parties.
A thing drawn tight enough to take little room for what it holds, and by the same root, an agreement drawn just as tightly between parties. Both senses share the same fastening.