In a major setback for President Trump’s economic agenda, the court ruled that he could not invoke an emergency power to set tariffs on imports.