Endesa said it would buy back up to $2.15 billion of shares in several tranches by the end of 2027.