Strange behavior: Extra css classes are NOT merged with the 'Search Block' form tag classes but with those of BLOCK wrapping the form tag i'm experiencing such 'strange' behavior with Drupal (v8.7.10) when trying to add css classes to the default Search Form form tag using MYTHEME_form_FROM_ID_alter hook, the classes are NOT merged with the form tag classes as expected but with those of the BLOCK wrapping the form tag itself.

this is my code:

function MYTHEME_form_search_block_form_alter(&amp;$form,\Drupal\Core\Form\FormStateInterface $form_state, $form_id) {
  $form['#attributes']['class'] = 'form-inline';
}


and this is the rendered output in question 

&lt;div class=" form-inline " data-drupal-selector="search-block-form" novalidate="" role="search" id="block-MYTHEME-search"&gt;
  &lt;form action="/search/node" method="get" id="search-block-form" accept-charset="UTF-8"&gt;
    &lt;div class="form-group"&gt;
      &lt;label for="edit-keys" class="sr-only"&gt;Search &lt;/label&gt;
      &lt;input title="Enter the terms you wish to search for." placeholder="Search .." data-drupal-selector="edit-keys" type="search" id="edit-keys" name="keys" value="" size="15" maxlength="128" class="form-search form-control rounded-0"&gt;
    &lt;/div&gt;
    &lt;div data-drupal-selector="edit-actions" class="form-actions js-form-wrapper form-wrapper" id="edit-actions"&gt;
      &lt;input data-drupal-selector="edit-submit" type="submit" id="edit-submit" value="Search" class="button js-form-submit form-submit btn btn-primary rounded-0"&gt;
    &lt;/div&gt;
  &lt;/form&gt;
&lt;/div&gt;


any thoughts ?
It's fairly straight forward PHP mistake $form['#attributes']['class'] is an array of classes

And by doing $form['#attributes']['class'] = 'form-inline'; you're saying forget whatever $form['#attributes']['class'] was before its now a string that contains 'form-inline'. So you're changing the variable from an array to a string.

Long story short you should be adding your class to the existing array with:

 $form['#attributes']['class'][] = 'form-inline';


Note the [] after ['class']

That explains why you have no classes coming out on your form. The issue about the classes on your outer div isn't related to this code and you must have something else going on too. Perhaps a block alter hook