Besides Crypto.SE Q&As like Understanding“Understanding the length extension attackattack”, the SkullSecurity.org website offers an explanation in their article “Everything you need to know about hash length extension attacks”. Here's an excerpt:
This again lifts the length extension attack problem described above, since a HMAC construction (which securely hashes data with a secret key) prevents length extension attacks. For details on how a HMAC construction achieves that, you can check the Crypto.SE Q&A How“How does the secret key in an HMAC prevent modification of the HMAC?” which explains that HMACs were designed to void length extension attack issues.
When trying to attack a HMAC,
…the attacker only controls variable-length input to the inner hash, not the outer hash…