Why does "for" not work

how does the Arduino IDE know if a pin assignment is "pin 5 - Analog (m168 pin 28)" or pin 5

It's the set of functions you use. pinMode, digitalRead, and digitalWrite refer to digital pins. analogRead refers to analog pins.

The two spaces overlap. There's a digital pin 5 and an analog pin 5 but they're not the same physical pin.

Can you - or anyone - shed light on how the IDE keeps those pins straight?

For digital pins, there's a pair of mapping functions / tables in the library. One map is used to determine the port. The other map determines the bit on the port.

I have no idea how analog pins are mapped to physical pins.