I have reviewd your question.
You have done like - for example: I add my custom block to referenceblock "product.info.addtocart" and in the template addtocart.phtml call it with getChildHtml('my_block_name'). But now my block is displayed two times.
Your way is correct. Now you just need to change in addtocart.phtml file.
Please remove getChildHtml('my_block_name') from your phtml file and please move <?= $block->getChildHtml('', true) ?> above add to cart button.
In addtocart.phtml file, there is already called getChildHtml('', true) ?> after add to cart button so you need to move this code above add to cart button and you have called your custom block as well before button so it was displaying two times.
Updated addtocart.phtml file
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
/** @var $block \Magento\Catalog\Block\Product\View */
?>
<?php $_product = $block->getProduct(); ?>
<?php $buttonTitle = __('Add to Cart'); ?>
<?php if ($_product->isSaleable()) :?>
<div class="box-tocart">
<div class="fieldset">
<?php if ($block->shouldRenderQuantity()) :?>
<div class="field qty">
<label class="label" for="qty"><span><?= $block->escapeHtml(__('Qty')) ?></span></label>
<div class="control">
<input type="number"
name="qty"
id="qty"
min="0"
value="<?= $block->getProductDefaultQty() * 1 ?>"
title="<?= $block->escapeHtmlAttr(__('Qty')) ?>"
class="input-text qty"
data-validate="<?= $block->escapeHtml(json_encode($block->getQuantityValidators())) ?>"
/>
</div>
</div>
<?php endif; ?>
<?= $block->getChildHtml('', true) ?>
<div class="actions">
<button type="submit"
title="<?= $block->escapeHtmlAttr($buttonTitle) ?>"
class="action primary tocart"
id="product-addtocart-button" disabled>
<span><?= $block->escapeHtml($buttonTitle) ?></span>
</button>
</div>
</div>
</div>
<?php endif; ?>
<script type="text/x-magento-init">
{
"#product_addtocart_form": {
"Magento_Catalog/js/validate-product": {}
}
}
</script>
Like this you need to move - https://prnt.sc/14o0qs3
So all the child blocks will be called which are called under referenceblock "product.info.addtocart"
getChildHtml('my_block_name')
multiple times inaddtocart.phtml
. Also you have removed added block from layout file.