I agree with @fatteneder, it is expected. To explain why, your code is an example of how syntactic loop fusion does not fuse across non-broadcasted calls (in this case, ternary ⋯ ? ⋯ : ⋯ is not broadcasted) although it is an admittedly opaque example.
Syntactic loop fusion transforms an expression like A .= f.(g.(h.(x))) into a single loop:
for i in eachindex(x)
A[i] = f(g(h(x[i])))
end
But loops are not fused across non-broadcasted barriers, so A .= f.(g(h.(x))) is equivalent to:
temp1 = h.(x) # one loop
temp2 = g(temp1) # no loop
A .= f.(temp2) # another loop
In your case, it might help to rephrase it as it as:
ifelse(true, A .= rand.(), nothing)
# vs
A .= ifelse(true, rand.(), 0)
This makes it clearer why the second example results in two separate loops (the first loop is just rand.() generating a single number). The first example is one loop, where rand is broadcasted to the shape A, producing different numbers…
Careful: ifelse(false, A .= rand.(), nothing) will still overwrite A, because ifelse is a function (not special syntax like if or ?) that evaluates all arguments before deciding which one to return.