Conditional for 404 page not work

You should wrap your enqueue/register function in your conditional, not your add_action()

You can try something like this using the is_404() conditional check

function enqueue_404_script() {
    if(is_404()) {
        //do what you need to do
    }
}
add_action( 'wp_enqueue_scripts', 'enqueue_404_script' );