Opaque type returns

I wrote this code to solve the problem of needing to switch between HStack and VStack in SwiftUI:

struct HorVStack<Content: View>: View {
    let needVertical: Bool
    let content: Content
    
    init(needVertical: Bool, @ViewBuilder content: () -> Content) {
        self.needVertical = needVertical
        self.content = content()
    }

    var body: some View {
        if needVertical {
            return AnyView(VStack { content })
        } else {
            return AnyView(HStack { content })
        }
    }
}

This works fine. What I don't understand is why I have to erase the type, even though each return type conforms to View? I feel like there's an interesting lesson regarding the underlying mechanics that I'm missing. Can anyone fill me in?

It has to be one specific type — with some you just keep your exact choice "secret" (to the compiler), exposing (to the user) nothing but the guarantee that it conforms to the protocol.
I guess the driving motivation is the ability to perform optimization, but that should be explained in the discussion about the proposal.

It tried that, also removing the @ViewBuilder attribute from the init. It compiles, but simply fails to render.

This is a thing that you can do with classes, sort of. Eh, no big deal if it's not possible, I'm just wondering what sort of hassle it'd take to make it possible. Nothing anyone ought to lose sleep over.