Shortcode not staying inside div tag

Maybe your form has a float property. So just add overflow hidden to parent div.

Take a look here: https://codepen.io/zecka/pen/jObvbmG

your code can be like that:

<div style="border: 3px solid green; margin-top: 1em; height: auto; overflow: hidden">
<h2>Blog notifications</h2>
<?php echo do_shortcode('[forminator_form id="9979"]'); ?>
</div>