How can I update the block content programmatically?
Placed blocks are stored in the config entity block. The IDs are more or less unpredictable but you can load the blocks by specifying properties:
$entity_type_manager = \Drupal::entityTypeManager();
$blocks = $entity_type_manager-&gt;getStorage('block')-&gt;loadByProperties([
  'plugin' =&gt; 'my_custom_block',
  'region' =&gt; $region,
  'theme'  =&gt; $theme,
]);

A code example to load all blocks placed for the custom block plugin, do some checks and modify the settings:
$entity_type_manager = \Drupal::entityTypeManager();
$blocks = $entity_type_manager-&gt;getStorage('block')-&gt;loadByProperties([
  'plugin' =&gt; 'my_custom_block',
]);

foreach ($blocks as $block) {
  if ($block-&gt;getRegion() == 'my_region') {
    $settings = $block-&gt;get('settings');
    // modify settings
    $block-&gt;set('settings', $settings);
    $block-&gt;save();
  }
}