How do I add custom tab in the user profile page?
Your problem is in the mymodule.routing.yml file, the big problem is the place of user: \d+, this line must be under the requirements: section, the other problem is the indentation. So the final code should be:

mymodule.account:
  path: '/user/{user}/custom'
  defaults: 
    _form: '\Drupal\mymodule\Form\MyModuleUserSettingsForm'
    _title: 'Custom Settings'
  requirements:
    _permission: 'access content'
    user: \d+


And of course you need the form class definition in src/Form/MyModuleUserSettingsForm.php

&lt;?php

namespace Drupal\mymodule\Form;

use Drupal\Core\Form\FormBase;
use Drupal\Core\Form\FormStateInterface;

/**
 * Class MyModuleUserSettingsForm.
 *
 * @package Drupal\mymodule\Form
 */
class MyModuleUserSettingsForm extends FormBase {

  /**
   * {@inheritdoc}
   */
  public function getFormId() {
    return 'simple_form';
  }

  /**
   * {@inheritdoc}
   */
  public function buildForm(array $form, FormStateInterface $form_state) {
    $form['title'] = [
      '#type' =&gt; 'textfield',
      '#title' =&gt; $this-&gt;t('Title'),
      '#maxlength' =&gt; 64,
      '#size' =&gt; 64,
      '#required' =&gt; TRUE,
    ];
    $form['submit'] = [
      '#type' =&gt; 'submit',
      '#value' =&gt; t('Submit'),
    ];

    return $form;
  }

  public function validateForm(array &amp;$form, FormStateInterface $form_state) {  }

  /**
   * {@inheritdoc}
   */
  public function submitForm(array &amp;$form, FormStateInterface $form_state) {  }

}


And a mymodule.info.yml file to complete your module (in this case named mymodule)

name: My Module
type: module
description: 'My module'
core: 8.x
package: Custom


Reference:
Structure of routes