Normally if you have shortcodes, it will be displayed as text (string) in Contact Form 7 fields unless you allow.
It’s because your shortcode echoes the output than returning it — shortcodes should not echo the output, but return it — unless in certain cases like complex HTML markup in the output, where you need to use output buffering.
You can place only the following code in functions.php and it will work:
<span class="hljs-comment">// Activate Shortcode Execution for Contact Form 7</span>
add_filter( <span class="hljs-string">'wpcf7_form_elements'</span>, <span class="hljs-string">'do_shortcode'</span> );