Snap to Grid unexpected result
When You set Z dimension to 0, it makes z-scale automatically to 0. It means that all Z - coordinates in model will multiply by 0:

 global coordinates = local coordinates * scale


When you select “Snap to Grid” it snaps globaly, and global coordinates needs to convert to local.  That means if you have scale 0.5 local coordinates must by twice bigger. So, the formula is: 

local coordinates = global coordinates / scale


So, if you set scale to 0 the formula will be:

local coordinates = global coordinates / 0


But division by zero is mathematically impossible. So it will raze an exception that reset coordinates.

See also: Why is it important to apply transformation to an objects data?