building an extension: how can I create a multiple-step form?
There are a bunch of ways to handle this.

Before proceeding down this path, consider if Webform-CiviCRM integration (for Drupal) or Caldera Forms-CiviCRM integration (for WordPress) will work for you - it will save you a lot of work if so.

If that's NOT an option, consider a) storing the data in the database (using the postProcess hook), b) storing the data in the $_SESSION variable, or c) using jQuery to fake having a multi-page form on a single page.