Lock snaped position at sides of the cube

So far I have a grid and the cubes snap and align nicely, the problem is that the cube which I am raycasting, snaps in the air, diagonally of the cube, the cubes snap to the sides as well, but I want to remove this air/diagonall snapping, what I tried was to put tags on terrain and blocks so it avoids the “air” but actually it still touches the edges of the cube and “hangs” in the air,

Here is a similar question that I answered previously that I believe is what you want as well:

The basic idea is to figure which side the Raycast hit was on and modify the blockCursor transform to be offset using the position of the object hit using the hit.normal property.