How does attaching analog inputs to digital pins actually works?

Are you referring to this table

No. Look up pin input threshold (or hysteresis) for typical values.

Figure 29.3.9 in Rev. 8161D–AVR–10/09 of the ATMega48PA-88PA-168PA-328P data sheet.

"I/O Pin Input Hysteresis vs. VCC" and "I/O Pin Input Threshold Voltage vs. VCC"