Caterpillar Inc. (CAT) posted quarterly earnings that beat Wall Street expectations as soaring electricity needs from artificial intelligence data centers continued to drive demand for the company’s power-generation equipment.