When one watches a series, granted they enjoyed it, the characters leave an impression in one’s mind similar to that of an actual person they appreciate.
You can feel attached to any fictional character, regardless of the medium in which they originally appeared.
To start with, everything leaves either a conscious or sub-conscious imprint in someone’s mind – varying thoughts either major or minor, they develop with extended exposure to the object or event in question. In the case of anime, as you continue to watch a series from start to finish it builds an alternate reality of sorts in your mind in which the events of the anime are like events of this new reality.
That is not to say this is actually a different dimension or something similar, rather it is an alternate area of ideals – much like as if you experienced an event in real-life, you would have a separate sub-set of memories correlating towards that event.
The ability to distinguish items from actuality and fiction relies on other mental factors – meaning memories can all be on a similar starting level of emotion save for those one wishes to put aside in relation to these other factors.
As progressive story and artistic (visual and sound) developments occur, attachment to these developments increases and different emotions begin flourishing – “I like this”, “I hate this”, “WTF is this”, all leading to distinct thoughts on a particular series.
These established groups of thoughts are refined in the same manner as any other thoughts – an anime one was captivated in took a depressing turn would likewise leave one feeling depressed to a certain extent depending on how they respond to other factors mentioned earlier, such as they sub-consciously take into account it’s only an anime and thus it has less of an effect.
Events taking place in an anime are processed no different than actual occurrences in real life until other factors come in.
As you watch a series you would feel as a character in the anime themselves would feel – similarly sharing their emotions as you are encompassed into the setting no different than an actual character as there is nothing to define such a boundary unless the person themselves does so.
A boundary preventing an associative feeling could be anything from not liking the series, to simply being occupied in reality (something rare these days).
As a series ends, it would be on similar level of internal conflict as moving away or losing a friend – an aspect of the series, like a character, has become equally as developed in your mind (a character’s traits and personality) as did the story’s outcome of such character, allowing you to attribute them no differently than reality.
All in all, it leaves you with the sad sentimental feeling after it’s all over.