Why do we need NMOS transistors for NAND gate?
if X or Y on both PMOS transistors is 0 , then both transistors will be open and the output will be 0 because there will be no flow of the current.

The output will not be '0', it will be floating.

That will leave any connected devices with a floating input and very susceptible to noise.
The connected devices also have input capacitance and these need to be discharged to drive the inputs to logic 0.
For high-speed logic the inputs must be switched quickly. The way to do this is to pull high and pull low directly.


Figure 1. Note that if we leave X and Y floating that it may be possible for the inputs to float to a stage where both the NMOS and PMOS transistors are partially on resulting in &quot;shoot-through&quot;. In this state enough current passes through the devices and they heat up and can burn out.