A brand and model name/number would help out tremendously here, but lacking that, I'll speak in generic terms.
If the cylinder was sliding FORWARD off the frame, and taking the crane/yoke with it (the part that the cylinder pivots open and closed on), it was probably missing the front sideplate screw or whatever the equivalent is in that design.
If the cylinder was sliding off REARWARD, then it was probably missing a small frame stud that normally sticks out behind and below the cylinder, on the left-hand side. In many designs, this stud (or frame projection), bearing against the rear face of the cylinder, is the only thing that keeps the cylinder from sliding off the yoke/crane when it is pivoted open.
If I had to guess, I'd say the first choice above is the most likely option. As you said, most of us would like to believe that all guns come from the factory with all their required parts, but as a person who once bought a new big-name autoloading pistol that had parts missing, I know that this isn't always the case.