For example, say someone gets the Unsung Hero badge for 10 or more zero score accepted answers, and 25% of total. Now, say someone goes and votes for some of their zero score accepted answers. Do they still have the badge? I'm not speaking specifically about this badge, but it's one easy example I thought of.
Once you get a badge, it is yours forever. A more interesting (at least I think so) example of this is if you have an answer that gets 10 upvotes, and then later gets many downvotes. Then even though you shouldn't have a nice answer badge anymore, you still do. But in this case, you wouldn't be awarded the next nice answer badge.
More about this can be found here.
As pointed out in Asaf's comment, one exception is that tag badges can be removed.
I will copy here the content of Arthur Fischer's comment from another question, where he provided more details: