I trust, your question is adressing Enketo (Webform), not Collect.
There is an appearance option for a group: compact (also working for repeats). See Collapsible groups · Issue #460 · enketo/enketo-core · GitHub. So, you can set all groups to appearance (column) compact, in the begin_group (or begin_repeat row.)
As always, groups without a label (or hint) are not show as group structure.
Here is an example
Collapse_Groups01.xlsx (10.5 KB)
Hint: As far, as we know, the appearance cannot be set in the form dynamically, e.g. with ${…} or if(…) for a “compact” text.
Also the following discussions may be helpful
https://github.com/enketo/enketo-core/issues/590 and
Visual display of groups in Collect - #8 by LN - Features - ODK Forum.
With the search function of the forum, you can find other previous discussions on this topic esp. Show sections collapsed/ navigation across survey.
@Kal_lam: Might be helpful to add it in the Help Center article, in the Reference table (XLSForm Reference Table) and in the XLSForm Docs.