Use it like this, this defined(‘REST_REQUEST’) will help you to disable running on the backend gutenberg block editor
function generate_new_member_form() {
if(defined('REST_REQUEST')) return;
ob_start(); ?>
// a form
// to generate this form there is some code that uses objects or functions
// only available in the front end
<?php return ob_get_clean();
}
add_shortcode('new-member-form', 'generate_new_member_form');