Set X to : round(sprite.X/gidsize)*gridsize
So for a 32 grid: round(sprite.X/32)*32 . YOu can use the same formula for snapping stuff to the Y axis too.
To make them "fall" on grid increments, use a move +Y:gridsize
Any other movements, have only at the gridsize, and it should never need to be set on the grid again.