Hide a block when viewing own profile page - Show when viewing other people's profile?
You can use hook_block_access()

/**
 * Implements hook_block_access().
 */
 function mymodule_block_access(\Drupal\block\Entity\Block $block, $operation, \Drupal\Core\Session\AccountInterface $account) {
  if($operation == 'view' &amp;&amp; $block-&gt;getPluginId() == 'block_id') {
    $uid_from_url = Drupal::requestStack()-&gt;getCurrentRequest()-&gt;get('user')-&gt;id();
    if($account-&gt;id() == $uid_from_url) {
      return \Drupal\Core\Access\AccessResult::forbiddenIf($block-&gt;getRegion())
        -&gt;addCacheableDependency($block);
    }
  }
  // No opinion.
  return \Drupal\Core\Access\AccessResult::neutral();
}


See more document function hook_block_access