How to rereference taxonomy? My goal was to create a taxonomy reference field in Drupal 8.2.

Consider these to field definitions on an entity. 

    // #1
    $fields[$field] = BaseFieldDefinition::create('entity_reference')
        -&gt;setTargetEntityTypeId('taxonomy_term')

    // #2
    $fields[$field] = BaseFieldDefinition::create('entity_reference')
        -&gt;setSetting('target_type', 'taxonomy_term')


Here is how #1 is documented:

  /**
   * Sets the ID of the type of the entity this field is attached to.
   *
   * @param string $entity_type_id
   *   The name of the target entity type to set.
   *
   * @return $this
   */
  public function setTargetEntityTypeId($entity_type_id) {


Looking at the description both should produce the same result - set target entity type.

The #1 creates me an input with autocomplete from page names and page types.

The #2 creates n input with autocomplete from taxonomy terms.

Why does this happen and what is #1 is meant to do?
As I answered at  Limit Taxonomy Term references to special vocabulary  if you want to create a custom entity_reference field on custom entity type try something like 

$fields['book_cat'] = BaseFieldDefinition::create('entity_reference')
   -&gt;setLabel(t('LABEL'))
   -&gt;setDescription(t('DESCRIPTION'))
   -&gt;setSetting('target_type','taxonomy_term' )
   -&gt;setSetting('handler','default' )
   -&gt;setSetting('handler_settings',['target_bundles'=&gt;['VOCAB_MACHINE_NAME'=&gt;'VOCAB_MACHINE_NAME']] )
   -&gt;setTranslatable(TRUE)
   -&gt;setDisplayOptions('form', array(
       'type' =&gt; 'options_select',
       'weight' =&gt; -1,
       'settings' =&gt; array(
           'size' =&gt; '60',
           'placeholder' =&gt; '',
       ),
   ))
   -&gt;setDisplayConfigurable('form', TRUE)
   -&gt;setDisplayConfigurable('view', TRUE);


AND  about  setTargetEntityTypeId :(Doc) 


  Sets the ID of the type of the entity this field is attached to.


and used when you want attach  field(s)  not  for referencing.