Stock indexes rebounded from a morning selloff after Trump’s tariff comments to finish the day with narrow gains.