Is "aftertaste" always a bad thing, and are there food products that are supposed to have some (specific) aftertaste?
It likely matter how you qualify 'aftertaste'.
I was watching a documentary on artificial sweeteners, and they specifically mentioned that with sucrose, there's a period of time where you continue to sense it. (I'm having difficulty finding what they called that variable, and what the time is for sucrose ... I want to say it was either 0.5 seconds or 1 second). So they don't want the sweetness to disipate immediately, but they don't want to to hang around too long.
For chilies and hot dishes, people might talk about 'attack' vs. 'sustain'. You can have a spicy dish that's initially powerful, or the ones where you can take a bite and it takes some time for you to get the impact of the heat.
I've used these two together to make deceptive drinks -- you load enough sugar into something that also has significant heat to it, and your mouth considers it to be overly sweet at first ... then after a minute, you start to notice the heat, and you go back for the sweet drink to cool it off, only compounding the problem. (this was a high school/college trick ... I want to say that it involved grape juice concentrate, Tobasco, and Mt. Dew, with the occassional addition of Tang (mixed so it was just a fluid, not dilted to normal strength).
What we discuss as 'aftertaste' are typically unintended longer-lasting flavors that are covered up by other flavors initially, but continue to persist after the other flavors have disipated. This is inherently different from flavor changing foods (typically candies), which typically use two different flavor compounds, one of which is encapsulated so that it releases after the other one.
And there are cases where we may want the lingering flavor, but it's assertive from the start -- mint is frequently used in this way. That might still qualify as an 'aftertaste' though. (although toothpaste isn't a food product)
As an autistic person - ie. a representative of a population known for having overly sensitive senses - virtually every food has an aftertaste that lasts around an hour at least.
You provided "spicy hot foods" as a single instance of a food with an aftertaste. This is nonsensical to me, since none of the spicy food I have tried (from American through European and Japanese to Thai) had an aftertaste that was qualitatively or quantifiably different than the aftertaste of chocolate, fruit sorbets, savoury cheeses, or vegetable salads.
(That is not to say that some foods don't leave a stronger aftertaste than others. Raw garlic or dried onion tend to stay with me for the rest of the day, for instance - but I recall other people being surprised that I can still feel it.)
Therefore, the question is most likely too heavily dependent on the individual biology of one's palate to have any reliable answer.