I know ifdef is not if, but if still only controls what gets assembled, not what gets run. The asssmbler doesn't really have enough information to create a branch because most values it has can be interpreted as multiple things. The simplest example is signed and unsigned numbers.

The 8bit value -1 is equal to 255. Really!
%11111111
or
$FF
=
-1
If interpreting the value as signed.
%11111111
or
$FF
=
255
If interpreting the value as unsigned.

All 8bit values where the leftmost bit is set can be interpreted as a negative OR a positive number, not just %11111111.

The programmer knows whether they want to interpret any given value as positive or negative. They choose the branch they need based on this. The assembler doesn't know and that's why it can't choose branches without more context. Check out this example similar to the above:

So what code should the assembler generate for the if statement? Should a branch be generated that would skip the load accumulator with 2, or should a branch be generated that doesn't skip the load accumulator with 2? There's not enough information given to figure that out. The above example might seem easy because the store of the negative constant is directly above the if. But imagine if the if was in a subroutine, and 255 and -1 were both stored to variable throughout the program. The assembler would have to guess what the programmer wants.

What ends up happening is that the address for variable is compared with the address for variable2. Those are things that can't change at runtime. Those are things the assembler doesn't have to make a guess for. If the address is greater, lda #2 is added to the program. If the address is not greater, those two bytes aren't added. No branch is generated either way.

Signed vs unsigned is only one of many things that means the context must be guessed. A number can also be 8 bit, or 16bit, or 24bit or 64bit, and you can compare a signed number to an unsigned number or an 8bit number to a 16bit number. This is also why you need multiple macros even for one type of comparison like I mentioned. Is -1 equal to 255? As far as the CPU is concerned, yeah. So if you want 255 to equal 255, but you also want -1 to NOT equal 255 you need macros you can provide the context of the values to. This is why C has you add types to things.

Languages without types usually solve the problem in a different way (variables are always signed, and can even be non integers to cover a large range of possibilities), but still usually have a way to force context when it's needed.