What do you mean "slid out"? The cassette is held on the freehub body by a lockring. Quick image grab but the cassette slides over the freehub and then you hold the whole thing on with the lockring. If it cassette came off then the lockring is clearly missing or very loose.
Or do you mean the axel came out of the drops? Maybe you didn't get it in straight.