How to redirect a wrong search on my wordpress website to the error 404 page?

A search shows the search template regardless of whether or not there are any results, which is either search.php or index.php if that template doesn’t exist.

If you want to load an entirely different template, you can use the search_template filter. Assuming your theme’s 404 template is 404.php:

function wpd_search_template( $template ) {
    if( ! have_posts() ) {
        $template = locate_template( array( '404.php' ) );
    }
    return $template;
}
add_filter( 'search_template', 'wpd_search_template' );