When you search on wp it automatically does a search query. In your code you make a new WP_Query to show 5 posts (which sorts by data by default) and there is no need to do that.
The best thing to do here is to leave the search.php
file as it is and use an action hook. You can add this to your child theme functions.php file.
function my_search_filter( $query ) {
if ( $query->is_main_query() ) {
if ( $query->is_search ) {
$query->set('posts_per_page', '5');
}
}
}
add_action('pre_get_posts','my_search_filter');