Combining `With`,` If` and SetDelayed

I just noticed that

With({x = 1}, If(x == 0, 0, 1))

returns 1 (as expected) but

y := If(x == 0, 0, 1);
With({x = 1}, y)

returns an unassessed form:

If(x == 0, 0, 1)

Can anyone explain what is happening?