How to avoid sand/gravel blocks to break when using in Minecraft mechanisms?

I believe I have determined the algorithm for sand and gravel falling; I previously wrote it up on Minecraft Wiki. I will use "sand" to refer to sand or gravel.

When sand is falling, it is an entity, just like all other freely moving objects. This entity falls under the influence of gravity until it hits something solid on its bottom. This causes an attempt to place a solid block at the cube-grid location containing the bottom-center point of the falling sand. Then, if that cube is occupied by a block (such as a slab or torch), the sand turns into a resource entity (the rotating cube you can pick up) instead.

So, just as conclusions from the above description, some other ways sand can break besides falling on torches:

  • A piston head was moving upward through the cube when the sand landed.
  • Another sand block landed in that cube while the sand was entering it.
  • A piston pushed a block into the cube the sand already partly occupied. (This is what happens in your tower-of-sand example.)

In order to avoid breaking sand with piston mechanisms, don't push blocks into space sand is currently falling into.