If you dig down through all the layers of abstraction, you'll see that many microprocessor / SoC devices expose GPIO through (at least) two hardware registers:
- Data register
- Direction register
The data register is of course what you read/write to get a value from an input pin, or change the value of an output pin.
The direction register controls whether a pin is an input or an output (or both). This affects the internal buffering / output driver circuitry associated with that pin.
For example, a GPIO pin configured for "input" (or reading) will be in a high-impedance (high-Z) state, so it presents little to no load to the connected circuitry. On the other hand, an output pin will usually be pulled to either Vcc or GND.
What you're seeing is this necessary direction register being abstracted all the way up to the Javascript level, where it seemingly makes no sense. As the electrical engineers, however. It is necessary.