Pin number question

I have a question about assigning pin numbers and how the arduino works. Like how does it know the difference between analog pins 0,1,2,3,4,5 and digital pins 0,1,2,3,4,5 in the set up? I understand you can use 14,15,16,17,18,19 , but I was under the impression once you do this it becomes a digital pin? Can anyone clarify this?

int button=2; // ???????

The int button = 2; statement is not what defines an analog vs. a digital pin. It is the function, analogRead vs. digitalRead that determines whether the analog to digital converter is invoked, or whether the current digital state of the pin is returned.

There are two connections from the pins used for the analog input. One path goes to a "standard i/o" processing, numbered 14... 19. One path goes to a multiplexer which connects one of those 6 lines to the ADC . Those multiplexer inputs are canonically called 0 ...5. One of them is choosen as soon as you invoke the analogRead() function.

This double use of pins is not unusual. Outside of the Ardiuino environment RESET and XTAL can also be "switched" to "standard i/o"...