Robin, in the 2nd case, yes you were attempting to preallocate the array. However, the array you preallocated is not the same array that you will end up with. In fact, the array you preallocated is immediately destroyed and replaced by a completely different array on the next line. Hence why Stephen says it's not preallocation.
In fact, more than unnecessary, your preallocation attempt is counter productive. Matlab waste time preallocating an array that is never going to be used and will be destroyed immediately.
There is a big difference between
In the first case, using indexing, you're assigning to one or more elements of the array. If the array is not big enough to start with, then matlab waste time making room for the new element(s). Hence preallocation is important.
In the second case, where there's no indexing, you're copying an entire array. Whatever was in the variable before that gets discarded, so preallocation doesn't work.