In both cases, the magnetic field doesn't change the electron spin. The difference is in the fact that the electrons in the Einstein-de Haas experiment are part of a lattice, and the ones in the Stern-Gerlach experiment are not.
In the Stern-Gerlach experiment, the electrons in the beam are effectively isolated, meaning that whatever spin state they had when they were put into the beam stays that way. The magnetic field gradient doesn't change the spin direction, it just exerts force in whatever direction the spin dictates.
In the Einstein-de Haas experiment, the electrons are part of a lattice with tons of other electrons at a non-zero temperature. Therefore, due to lattice interactions, the spin of each electron is constantly fluctuating, regardless of the presence of a magnetic field. In the absence of a magnetic field, there is an equal probability of detecting the electron in any spin configuration. An applied magnetic field makes some spin configurations (namely, those parallel to the field direction) lower energy than others, so it shifts the probability distribution toward the direction parallel to the field*. The stronger the applied field, the more heavily the distribution is weighted in that direction. So the magnetic field doesn't really change the direction of the spin, it just changes how much time the fluctuating spin spends in a particular configuration.
*In some cases (see antiferromagnetism), interactions between adjacent electrons can be more important than an external field, and lead to unusual effective potentials that make for weird spin arrangements. Typically things happen as above, though.