I could not comment on the answer by @Chris, therefore the new post.
The direction command has it's limitations. The directions can only be set when the nodes in the subgraph are not connected to anything outside the subgraph. Else, the top level layout is used.
See: https://docs.mermaidchart.com/mermaid-oss/syntax/flowchart.html#limitation