In Drupal 8 and later, addTag is a method used with entity queries to attach a tag to the query. This allows for the customisation or alteration of the query by other modules. Tags are used to identify queries and provide a mechanism to alter them using hook implementations, such as hook_query_TAG_alter.
Here's a brief overview of how you can use addTag in a query: