you get a wrong behavior because two gates are not implementing the NAND function (see attachment). When you use 3D gates you should pay attention at the coupling between input magnets and ANC. Magnets lying on the same physical plane are coupled anti-ferromagnetically with ANC. On the contrary, inputs placed above or below the ANC are coupled ferromagnetically.
Please have a look at the following papers: