The use of "return" in PowerShell is there to break out of a function somewhere other than the end. Doing a 'return $var' is the same as doing '$var | Write-Output; return'. So, you can see what's happening. PowerShell doesn't just return what follows the 'return', it shoves all uncaptured output into the pipeline.
From a PowerShell prompt, if you were to do this: "@()" you'd get nothing. If you did "@(1,2)" you'd get two lines of output (one for each element of the array).
What's happening is that the variable $var is being fed into the pipeline, it's not being returned as a single object of type [array].
Trying to "fix" this isn't going to work because this is the way PowerShell works, it's not 'C', 'Pascal", 'C++', 'C#', 'Python', etc. Whether it's a bug or a feature depends on your (or your script writer's) understanding of the language. If you want an array to always be treated as an array, try using something like this:
function flat{
$arr = @(1)
if ($arr.length -lt 2){
,$arr
}
else{
$arr
}
}