Fernando Alonso will race on in Formula 1 with Aston Martin into the 2027 season having extended his contract.