Create a custom block programmatically and specify region and pages on which created block must shown on
You have to create a block config entity to place a block:

use Drupal\block\Entity\Block;

  $placed_block = Block::create([
    'id' =&gt; 'block_machine_name',
    'theme' =&gt; 'classy',
    'weight' =&gt; 0,
    'status' =&gt; TRUE,
    'region' =&gt; 'footer',
    'plugin' =&gt; 'block_content:' . $block-&gt;uuid(),
    'settings' =&gt; [],
    'visibility' =&gt; [
      'request_path' =&gt; [
        'id' =&gt; 'request_path',
        'negate' =&gt; FALSE,
        'pages' =&gt; '/path',
      ],
    ],
  ]);
  $placed_block-&gt;save();