Normally, cracks in plaster are caused by small amounts of movement in the building itself, and that's something you really can't prevent.
For example, clays absorb moisture and swell up. If your house is build on soil with a high clay content, then during a drought, the soil can dry out a lot, and that means the clay (and soil) will shrink. After a rain, the clay will swell. The shrinking and swelling of the soil depending on it's moisture content can cause your house to move, and the lifting by the clay won't necessarily be uniform. And, that's just one of the things that can cause the ground to move, which in turn will cause your house to move, and cause the plaster walls and ceilings in it to crack.
There is no "once and for all" way to prevent plaster cracks from opening and closing short of stopping the house from moving, and if the ground moves, the house will move.
If you live where the ground freezes in winter, then the freezing of the moisture in the ground can cause frost heave, and that can toss a house around like a cork on the ocean.
What I do to "fix" hairline cracks in plaster is to use a wide (4 inch, say) putty knife to pack joint compound into the crack, and then immediately wipe the excess joint compound off with a damp sponge. The result is joint compound in the crack, but not all over the wall.
But, that won't stop your house from moving, and won't stop the crack from opening and closing either.