The sacrifice endured. The protective charm on 4 Privet Drive did not.
Lily's protection had several aspects to it.
- Primarily, it shielded the baby Harry from Voldemort's Killing Curse.
- Once Dumbledore cast a specific charm, the protection was extended to Privet Drive for as long as Harry was a child and as long as he could call that place home. This part of the protection is both time-sensitive and location-specific.
- Once Voldemort took Harry's blood as part of his regeneration, then and only then did the protection enter Voldemort. Only then was Harry's lifeforce tied to Voldemort's.
The nature of Dumbledore's protective charm
The part of the protection that ended when Harry turned 17 was the part relating to Privet Drive.
"You would be protected by an ancient magic of which [Voldemort] knows, which he despises, and which he has always, therefore, underestimated - to his cost. I am speaking, of course, of the fact that your mother died to save you. She gave you a lingering protection that he never expected, a protection that flows in your veins to this day. I put my trust, therefore, in your mother's blood. I delivered you to her sister, her only remaining relative...She may have taken you grudgingly, furiously, unwillingly, bitterly, yet still she took you, and in doing so, she sealed the charm I placed upon you. Your mother's sacrifice made the bond of blood the strongest shield I could give you...While you can still call home the place where your mother's blood dwells, there you cannot be touched or harmed by Voldemort. He shed her blood, but it lives on in you and her sister. Her blood became your refuge. You need return there only once a year, but as long as you can still call it home, whilst you are there he cannot hurt you."
(Order of the Phoenix, Chapter 37, The Lost Prophecy)
Here we can see the distinction (subtle though it may be) between the protection, which Harry has with him at all times, and the charm which relates exclusively to Harry's stay at Privet Drive. The purpose of this charm was to harness Lily's protection in such a way that it stopped Voldemort or his followers harming Harry at Privet Drive. The charm only utilised Lily's sacrifice to extend Harry's protection; it was not the protection itself. It was time-sensitive - Dumbledore's charm had an expiry date, so to speak. The reason why Dumbledore cast the charm that way when Harry was one was probably in anticipation that the adult Harry would want to move on and live elsewhere. Or maybe the charm only works on children. Either way, it was Dumbledore's charm that broke on Harry's 17th birthday, not Lily's protection.
I think it's understandable that you're confused about this point. The first two quotes in the question do appear to be contradictory. The first one is by Harry, who rightly states that it is the protective charm that is due to expire. The second is by Moody, who makes a somewhat misleading statement.
"We can't wait for the Trace to break, because the moment you turn seventeen you'll lose all the protection your mother gave you.
(Deathly Hallows, Chapter 4, The Seven Potters)
I think that this statement can be explained by Moody knowing less about the charm than Harry does. Even if Moody knows better, he's clearly in a hurry in this scene. Out of fear of imminent attack, Moody repeatedly tells people to cut the niceties and get on with executing Harry's escape. For that reason, he probably didn't take the extra time to draw the distinction between the protection and Dumbledore's charm.
The nature of Lily's protection
The protection doesn't make him bulletproof forever. He isn't permanently invulnerable. What helped Harry survive Voldemort's Killing Curse in the Forest was Voldemort's use of Harry's blood in his regeneration (number 3 on my list). If Voldemort had used any other wizard's blood then Harry would not have survived that spell. And, at the end of the Battle of Hogwarts, Harry is a mere mortal much like anyone else.
However, Harry does continue to have Lily's protection even after the events of the books. This protection (confusingly enough) neither relates to the original attack in the Potter residence, nor to Dumbledore's charm on Privet Drive, nor to Voldemort's regeneration. It's what Dumbledore calls in the quote above "a lingering protection that he never expected, a protection that flows through your veins to this day". What form this protection takes is never really explained. However, Harry carries it with him wherever he goes. It's with him forever.
"Your mother died to save you. If there is one thing Voldemort cannot understand, it is love. He didn't realise that love as powerful as your mother's love for you leaves its own mark. Not a scar, no visible sign...to have been loved so deeply, even though the person who loved us is gone, will give us some protection for ever. It is in your very skin."
(Philosopher's Stone, Chapter 17, The Man With Two Faces)