Short Version
Dataset
layouts are generated from complex heuristics aimed at maximizing interactive usability rather than static layout predictability. The heuristics change between releases making it difficult, and sometimes impossible, to force a particular static layout.
Long Version
A long-standing criticism of Dataset
is that its operation is driven heavily by heuristics and those heuristics can seem quite arbitrary at times. The present question provides an example.
In this case, the layout algorithm is trying to decide how best to utilize space to render the data. It is triggering off the number of elements in each row. For up to four elements, version 12.1 renders each row as a list within a single cell:
With[{data = ConstantArray["x", 4]}, Dataset[<|"a" -> data, "b" -> data|>]]

For between five and eight elements, each row is rendered as a vertical block of cells:
With[{data = ConstantArray["x", 5]}, Dataset[<|"a" -> data, "b" -> data|>]]

Only when rows have nine or more elements do we see the layout shown in the documentation:
With[{data = ConstantArray["x", 9]}, Dataset[<|"a" -> data, "b" -> data|>]]

In general, the heuristics which govern layout are complex and take many factors into account. Those factors include object length, object type, whether objects in collection are all of the same type, rendering space available and more. Furthermore, these heuristics change between releases. So even when a work-around is found that generates a particular look there is no guarantee that the next release (or even paclet update) will disturb it.
Editorial Comment
I think that Dataset
was designed for ad hoc interactive use, not as a means to generate static layouts with particular forms. Rather, the goal was to allow the user to be able to view and drill into any data structure no matter how complex or large it was. The heuristics are trying to maximize interactive (not static) usability by deciding when to pivot, spread, elide or permit drill-down into data. They do not always guess correctly.
The documentation is silent on this issue which only adds to the frustration when we get an unexpected layout. Perhaps it ought to acknowledge this situation under Possible Issues and mention more predictable static layout alternatives like Grid
, TableForm
or TableView
.
Dataset[{<|"apple" -> fruit, "carrot" -> vegetable|>, {sweet, crunchy}}]
. But I don't know if this syntax will interfere with operations on the association. $\endgroup$