You need to use pullup or pulldown resistors with any switch, otherwise the voltage is undefined when the switch is open (aka "floating" input).
CMOS logic takes such low current (*) that the voltage on an input is affected by nearby wiring and leakage if not explicitly connected to some defined voltage through a resistor.
(*) can be less than 1 picoamp