How do I assign a specific role to each newly registered user?
I had to implement a similar feature in a site, where:


Users are not required to verify their email address
When users create an account, they get the unverified account role
Once the users verify their email address, the unverified account role
is removed, and they get a confirmed user role


It is pretty similar to what drupal.org does nowadays; I am just using different roles, and custom code that is different from what drupal.org uses.

I didn't use the Auto Assign Role module, since there isn't a working version for Drupal 8. I didn't use the Registration Role module, since it adds the roles to every account being edited, including the accounts with the administrator role.

I used a custom module (which I was already using for other purposes), where I implemented hook_ENTITY_TYPE_presave() with code similar to the following one. 

function mymodule_user_presave(UserInterface $user) {
  if ($user-&gt;isNew() &amp;&amp; !$user-&gt;hasRole('unverified account')) {
    $admin = FALSE;

    foreach ($user-&gt;getRoles(TRUE) as $id) {
      $role = Role::load($id);
      if ($role-&gt;isAdmin()) {
        $admin = TRUE;
        break;
      }
    }

    if (!$admin) {
      $user-&gt;addRole('unverified account');
    }
  }
}


hook_ENTITY_TYPE_insert() and hook_entity_insert() are the wrong hooks to use, since they are invoked when the entity is already saved in the database. Calling the save() method on the entity passed to those hooks will cause all the hooks invoked when an entity is saved to be invoked again, causing an infinite loop.