Is there a way to make a piston push any block in front of it, when that block is placed?
Place a piston 1 block above the water, with a redstone torch diagonally 1 down and 1 in the direction the piston is facing. Place solid blocks to the same side of the piston and redstone torch, and then place a piece of redstone dust on the lower cobblestone:
You should then place your sand on top of the redstone torch:
You could build this 2 further down, but you'd have to deal with making sure the water doesn't wash away the torch or redstone dust.
The way I would do it is have a torch power the block you're putting down, and transferring that power to the piston (so that it's powered when you put a block down, and unpowered when the block is pushed back).