It's because .357 and .38 cases are identical in all measurements except for length. .357 magnum cases are longer so that it's impossible to put a .357 magnum round into a .38 SPL revolver, since the chambers get narrower towards the front. This is because the bullet is narrower than the case, and having the bullet bounce out of the chamber and into the barrel through an oversized hole wouldn't be very helpful to the accuracy or velocity.
Revolvers are able to do this because of how they headspace the cartridge. Headspace refers to how far the cartridge goes into the chamber. .357 magnum and .38 SPL revolvers headspace on the cartridge rim. The cases are shaped kind of like a tube on top of a plate. The plate part, the "rim" of the cartridge, sticks out wider than the tube, and is pushed against the back of the cylinder when the rounds are loaded.
Automatics usually headspace on the mouth of the cartridge--the end of the tube where the bullet sticks out--instead of the rim. So you may notice that a lot of automatic cartridges, such as 9mm parabellum and .45 ACP, are "rimless." They still have a rim, but it's the same diameter as the main body, or sometimes slightly narrower. The rim on those cartridges is for the extractor to grip onto, to pull the round out of the chamber. It doesn't have any effect on headspacing.
Because most autos headspace on the mouth, it's usually not safe to fire shorter versions of rounds in an automatic, unless you get a seperate barrel. They will usually go "bang" if you try it, but there's also a chance it could go "BOOOOOM." Or you could break the extractor, since that would be the only thing holding the cartridge in place, by the rim. And since the extractor isn't meant to hold the case still while the firing pin whacks it, that could over-stress the part. So you shouldn't try firing .40 S&W out of a 10mm, or .380 ACP out of a .38 Super, for example.
Also there are some revolvers chambered in auto cartridges. Some headspace on the mouth, like an automatic, but some headspace on a clip which goes around the base of the cartridge, acting like a rim would. The ones that headspace on the mouth can't use shorter cartridges, but the ones that headspace on a clip will usually tolerate shorter cartridges, as long as all other dimensions are identical.
So yeah, as a general rule, you can fire shorter versions of cartridges through guns that headspace on a rim or a clip, as long as the other dimensions are identical. So .45 Long Colt can be fired through a .454 Casull revolver, and .22 Shorts can be fired out of a .22 Long Rifle revolver. But .22 Long Rifles can't be fired out of a .22 Magnum revolver, because the .22 Magnum case is wider than the .22 LR case, in addition to being longer.