Understanding (and fixing) non-manifold geometry
When you turn on edge-snapping, then try to snap a point to a vertex, the point will end up on the edge, not on the vertex.
Try the same procedure you gave with vertex-snapping enabled instead of edge-snapping. Everything should work as you expect.
Alternatively, when you merge points that are not in the same place, you can increase the merge distance. Or you could select a group of points you want to merge and merge to center, but your resulting cube is liable to be out of square.