You found out why you cannot have floating inputs on a CMOS circuit. That is an undefined state for the inputs and, due to their high impedance, can float to any voltage. Touching the pins will add or subtract charge on the gates, randomly changing their state.
All inputs must either be tied to logic high or logic low, even unused ones.