In my case, I wasn't able to edit the shortcode, so I added wpcf7_form_id_attr filter in my functions.php file like following:
wpcf7_form_id_attr
functions.php
add_filter('wpcf7_form_id_attr', fn() => 'wpcf7-' . WPCF7_ContactForm::get_current()->id());