Will any 10 speed cassette work with a 10 speed shifter?
Shimano and SRAM cassettes of the same speeds (up to 11 speed) are all basically compatible with each other. The overall cassette width and individual sprocket widths and spacings are standardized for each number of speeds.

(This does not mean you can use any 10 size speed cassette in a drivetrain of course, as the derailleur has to be able to handle the cassette sprocket size range.)

Because sprocket widths and spacings are standardized, all shifter/derailleur combinations for a given number of speeds move the derailleur cage the same amount per click, to match with the cassette sprocket spacings. The amount of cable pulled by the shifter per click differs between Shimano and SRAM but this is compensated for by the derailleur actuation ratio. 

If your chain is coming off the innermost or outermost sprockets you need to adjust the derailleur limits. If the chain is overriding the sprockets under hard pedaling check chain and cassette sprocket wear. Note that a worn chain accelerates wear on cassettes and chainrings. I recommend getting a chain wear gauge as they are cheap and easy to use.