In some book, it's written that layers making the 3d structure must be hexagonal for close packing of spheres. But suppose we have a simple cubic sheet and another one on top of it, with which we try to fill depression between spheres.
By calculation, I get that minimal distance between layers is $\sqrt2r$ and calculating efficiency from this structure and taking unit cell as what comes out to be effectively end centric with $Z=2$, $a=b=2r$ and $C=2^{3/2}r$. I get exactly the ratio calculated by Gauss. Is there a discrepancy of some kind regarding close packing?
There is no contradiction. What you describe is the face-centered cubic packing, which is one of two most regular lattice packings of spheres with optimal density.
It can also look hexagonal from a different angle: see Wikipedia.