hook_form_FORM_ID_alter being called twice (even before submit) I want to make some changes to the "Content" page. 
The ID of the form is views_form_content_page_1, so I made a quick test (after drush cr of course):

function my_module_form_views_form_content_page_1_alter(&amp;$form, FormStateInterface $form_state) {
  kint($form);
}


When I go to the page, the $form is being printed twice by the devel. I checked, all of the array items are the same. If I do kint('cat');, then it will print cat two times. 

Why is this happening? Of course I could make it work, that my action will run only once (eventho drupal tries to run it twice) but I would like to rather solve this one, and understand if it's a bug, and why it is happening.
It has to do with the fact that Drupal redirects after the form submit. So after a form submit you will make 2 requests: the form submit and the redirect. Hence the 2 messages in your hook_form_alter(). 

You can disable this redirect by calling $form_state-&gt;disableRedirect() in your form submit handler. By disabling the redirect the form values will be preserved in the form. The redirect is in place to 'clean' the form inputs after submission.