How to stop WordPress Search form from searching only in current page?

When you omit the action attribute from the form tag, it defaults to the current URL. Give an explicit URL for the form’s action to direct it to a specific URL-

<form class="form-inline" role="search" action="<?php echo home_url( "https://wordpress.stackexchange.com/" ); ?>">