Programmatically specifying pathauto alias
Pathauto 8.x is already hooking into the hook_entity_$CRUD_OP() hooks of D8 to do its work. Thus, trying to do this via a hook_entity_insert() means your module hook might fire before/after pathauto has set its alias (depending on module weight).

Instead of doing this, you should use the API functions of pathauto to alter its behavior. For example, hook_pathauto_pattern_alter() or hook_pathauto_alias_alter() will let you alter the pattern/alias prior to generation/saving. 

See pathauto.api.php for more info.