It's often helpful when you're stumped by something to evaluate individual pieces in the Julia REPL to see what they do. In this case, if you evaluate randn(1) by itself, you'll see something like this:
julia> randn(1)
1-element Vector{Float64}:
1.1308545762168796
It returns a single-element vector containing a random floating-point value. Now, when you do
B[2^N] = randn(1)
you are trying to assign a vector as the last value in an array of floating-point values. That might work in some languages like R and Matlab where there aren't actual scalars and scalars are instead approximated by single-element arrays (this has a host of problems which I won't go into here), but in Julia a scalar and an array containing a scalar are different things. That's why you get this error.
So how to fix the error? There are a number of ways. You could extract the value on the right hand side before assigning it like so:
B[2^N] = randn(1)[1]
That works, but it unnecessarily constructs a single-element vector only to immediately throw away the vector and take the element out of it, which is slow and wasteful (probably doesn't matter here, but if this was in some performance-sensitive code you wouldn't want to do that). Instead, you can generate just one scalar value not in an array by calling randn() with no dimension arguments:
julia> randn()
1.2990863797503651
This value can be assigned into B as is:
B[2^N] = randn()
That is the best way to do the specific thing you're trying to do here.