You are probably thinking of an ESP8266 board.
Traditionally, Arduino pin numbers are only arbitrary identifiers for a pin, completely abstracted from the low level pin identifiers to which they are mapped by the core variant code. The core functions take Arduino pin numbers as parameters and then derive the associated low level identifiers from the Arduino pin number.
The developers of the "esp8266" core took a non-standard and confusing approach to pin mapping where they made the Arduino core API use the low level GPIO numbers, then used macros to map the pin numbers/names as marked on the board silkscreen to the lower level GPIO number. So indeed the numeric component of the macro doesn't necessarily match to the GPIO number when using those boards. For example:
When using one of those boards, I do recommend using the macro simply because this is the only way to have your code match what is written on the board's silkscreen.
However, this discussion started as being about the UNO R4 WiFi. The developers of that board's "Arduino UNO R4 Boards" platform used the standard approach for pin mapping, but then added these Dn macros to the variants as an afterthought. So when using one of the platforms that does standard pin mapping, you can use the integer Arduino pin number, or the Dn macro interchangeably.
I guess you never tried to compile the code for many different boards then. Many significant boards platforms do not define Dn pin names. I just did a quick survey of some of the boards platforms that happened to come to mind and found they are not defined by any of these:
- Arduino AVR Boards
- Arduino SAM Boards (32-bits ARM Cortex-M3)
- Arduino SAMD Boards (32-bits ARM Cortex-M0+)
- Arduino megaAVR Boards
- Adafruit AVR Boards
- Adafruit SAMD Boards
- ATTinyCore
- DxCore
- MiniCore
- MegaCoreX
- MightyCore
- SparkFun AVR Boards
- Teensy
You would also find that it fails to compile for most ESP32 boards, since they are only defined in a small subset of the core variants.