U.S. stocks ended mostly higher on Wednesday, with the S&P 500 and Nasdaq snapping their four-day losing streak, as investors digested the latest comments from President Donald Trump on tariffs.