Because A0, … are all macros defined in the system and D12 etc. are not, they are just simple variables.
A0 on a UNO translates into 14, which is the pin number of the analogue input if you want to use it as a digital pin.
It is very often misused to address a pin in an analogRead call, but the system code is smart enough to detect and correct this.
its really confusing for a beginner in this stuff, indeed.
Dont know, what the inventors had in mind
with not uniqually name and adress pinadresses independent of capabilities..
They want to make it simple and yet cover an ever growing number of different processors on different boards.
The use of the Ax to refer to the digital use of analogue pins was not in the original Arduino software but introduced about ten years ago, because different processors have different physical pins for the analogue capable pins.
So in order for the same sketch to work on a wide number of processors you need to abstract the pin addressing system. The concept of a pin itself is an abstraction of what really happens on a processor, in that all output is done 8 bits, or one byte at a time. On other processor types this is done 16 or 32 bits at a time. So the system software has to make it look like you can change one pin at a time even though when it comedown to it you can’t actually do this.
The popularity of the Arduino system is that this complication and portability is maintained and hidden from the user.
use 12 instead of D12, 11 instead of D11 and so on. I think you get the point.
See the built in examples. there is no example with Dxx ... its always xx when "digital" pins are used.
See the file pins_arduino.h in the right folder (e.g. hardware\arduino\avr\variants\standard) to see what was predefined or what should be available as constants can differ from board to board.