Hello,
The problem is that you are doing an inline replacement. Using this kind of replacement, block elements are removed and only the variable is replaced.
We recommend you to read the information available on:
https://www.phpdocx.com/documentation/introduction/html-to-word-PHP (Inserting HTML into Word templates section)
https://www.phpdocx.com/api-documentation/templates/replace-variable-html-Word-document (Parameters section)
MS Word allows setting the alignment to paragraphs, tables, images... You need to use a block type replacement to set a new alignment:
$docx->replaceVariableByHTML($section, 'block', $html);
Regards.