What does "to come undone" actually mean?
In the literal sense, this refers to something becoming untied, unwrapped, unfastened, etc. For example:
Be careful with that gift. If it comes undone, they'll be able to see what is inside.
In the figurative sense, it means that something has either not gone as planned, or has failed in some way. E.g. a plan can come undone meaning it hasn't worked as expected. A person can come undone meaning that they have lost their composure or self-control.
Andy came undone when Ann left him for Steve.
In modern English, it is the counterpart of "do up", meaning to fasten (by whatever method - tie, glue, knot, zip, velcro). It is nearly always used literally, but when it is used of a person, it normally means that their clothing has become unfastened.
In older English, it could be used in a more abstract sense, so "I am undone" could mean something like "my life (or my wealth, or my reputation) is ruined". Modern readers often find the phrase amusing, because its modern meaning is so closely related to clothing.
If a strap or a knot or some other kind of binding comes undone, it opens by accident and no longer binds anything.
If a plan or a scheme or a plot comes undone, it does the same thing. This is a figurative sense that parallels the literal sense.
Reinforcing what Colin said, "undone" means ruined. Two cites:
And the posts of the door moved at the voice of him that cried, and the house was filled with smoke. Then said I, Woe is me! for I am undone; because I am a man of unclean lips, and I dwell in the midst of a people of unclean lips: for mine eyes have seen the King, the Lord of hosts.
-- Isaiah (KJV) 6:4-5
and
She's come undone
She didn't know what she was headed for
And when I found what she was headed for
It was too late
-- The Guess Who, "Undun", 1969