Adding multiple taxonomy terms to a node via code
The object orientated way would be to use appendItem() from FieldItemList:

$node-&gt;field_tags-&gt;appendItem([target_id =&gt; '1']);


But as the field object provides an array interface you can add items to the field the same way as in a php array:

$node-&gt;field_tags[] = '2';