Exclude JS file from 404 error page

There is is_404(). I normally use it to do just the opposite, to add CSS and JS animations which are specific to the 404 error page. In your case that would be:

function wpse_339946() {

    if ( ! is_404() ) {
        wp_enqueue_script( 'tracking-js', get_template_directory_uri() . '/js/tracking.js' );
    }
}

add_action( 'wp_enqueue_scripts', 'wpse_339946' );