You're right. Undone has (at least) two meanings. One is to reverse an action that has already been done, like the "UNDO" command on a computer.
To "come undone" literally refers to dressing, specifically to something that is buttoned or fastened or tied. In this context, "come undone" means to come apart, to become unbuttoned, unfastened, or untied. "She had her hair in a ponytail, but the rubber band holding it broke and her hair came undone."
That's the literal meaning, It has then been extended to mean "to behave badly, to lose control of ones' self."