Caterpillar’s stock surges after the biggest earnings beat in five years, as demand for data-center construction provided a boost.