Many anime do not follow the manga history and are made shorter. However there are a few that do follow it or try to finish the history with the manga like the big three (Naruto, Bleach, One Piece), Death Note, and FMA Brotherhood. But others finish the anime without the real ending like FMA, Ouran High School, Pandora Hearts, Tsubasa Reservoir Chronicle. Why is this so? Is it because of the high cost? Or the lack of popularity?
The television broadcaster allots a specific number of seasons for the anime, depending on commercial considerations, such as popularity of the source material (manga), target audience, timeslots available, etc. If the manga would not conclude by the time their allotted season ends, they usually create an alternate ending, so that the audience does not feel like they abandoned the series.
The more popular series such as Naruto or One Piece can reasonably expect that they would get several seasons, till the manga ends and hence can follow the manga closely. However, such anime could also end somewhat abruptly, if the broadcaster decides to not allot them any more seasons at some point, as it happened with Bleach after the Fullbring arc, for example.
In some cases, when the anime production company works closely with the mangaka, they can keep their ending consistent with the manga, even though the manga has not been published, but this is rare.
Generally with cases like Soul Eater, Ouran, Kaichou wa Maid-Sama and Ao no Exorcist is that they've run out of source material or that the manga simply hasn't reached far enough past that point to continue the anime. The first Fullmetal Alchemist anime came out when the manga wasn't anywhere near done, and therefore branched off completely after
Hughes was killed.
It's hard to say, since there's a lot of reasons.
Some are just horrible decisions.
Some are money motivated.
Tokyo Ghoul is a recent example of how NOT to adapt a manga into an anime, which basically ruined it FOR NO REASON (since the manga was almost in it's 2nd to last arc when the anime started development, so all the material they were basing the anime on was already there and ready to use). (Even anime-only viewers that had never read the manga were able to pick up on the fact that something didn't feel right....nice action scenes to be sure (when the whole screen wasn't blacked out since someone decided it was a brilliant idea to run a gory series like TG on a network with strict censors), but the plot, characters, and pacing was meh...a lot didn't even realize it was supposed to be a seinen series and mis-type it as shounen when describing it)
Rearranging events that made no sense to rearrange to begin with (introducing several noticeable plotholes, such as Kaneki actually getting WEAKER as the story progressed, since in the first arc (after the intro arc) he demonstrates sudden melee fighting skills, but none in the 2nd arc in his fight with Amon, where as in the manga it was his inability to control his Kagune in his fight with Amon (and lack of fighting skills that forced him to use it) that convinced him that he should learn to fight without relying on it until he could control it properly as to not endanger his friends and allies, which is why he'd become much stronger during the Gourmet arc).
Completely altering the MC's personality into a helpless useless baby that did nothing worthwhile until the last arc, where as in the Manga he was just understandably lost/confused with the completely new life he'd been forced into and adapted to it rather quickly and well. (one of the biggest differences being in the first episode/chapter, where defining character moment was changed completely. When faced with a monster and threat of death, Manga Kaneki fought, while anime Kaneki fled). Also the fact that Manga kaneki discovered most of the stuff about being a ghoul by himself, where as anime Kaneki has to be told every little thing.
A similar thing was done to Shinichi in the new Parasyte anime, but only for the first episode or two at which point he jumped back to his manga incarnation (which according to Madhouse, was because modern anime fans have had their brained rotted out by years of terrible anime that they can't properly detect subtle shifts in personality unless they're beaten over the head with it with extremely blatant evidence of personality shifts such as dramatic physical/psychological changes).
Leaving out A LOT of character development across the board. (this is ESPECIALLY bad for a seinen series being adapted because one of the biggest differences between a seinen and shounen is that seinen tend to have much deeper looks into character development, where as shounen is generally more superficial or glossed over in favor of focus on action due to being marketed to younger audience with less attention span and wanting to see more explosions (Obviously the only real definition for Shounen vs Seinen is which magazine the source material ran in, which results in stuff like Death Note or AoT being shounen despite having the sort of themes and depth you expect from a seinen.)
FILLER SCENES in an anime that was already way too short, that could've been better spent on the cut character development or scenes actually in the manga that were pretty important but cut in the anime. This is the WORST kind of filler. If the anime had been ~24 episodes and they added a bunch of filler that expanded and fleshed out the world to get them to the point where the anime ended (if properly adapted the beginning through Aogiri arc to it's full conclusion, rather then simply stopping in the middle like the anime did would've taken about 18-19 episodes), AFTER they'd properly adapted everything that was supposed to be there, then that's good filler. But when you're already having to prune the story (and some element could be pruned without hurting the overall experience, like Amon running out to dig up Hinami's father's mask to prove the mother and child were ghouls, which showed Amon was dedicated, albeit recklessly so to hunting down ghouls, but wasn't critical to his character since he showed his revolve and beliefs A LOT)) to get it to fit into the Season length, filler shouldn't exist at ALL. Taking Hinami's father's episode scenes as an example...IF the anime had the run time to allow it, AND it was treated as a flashback instead of currently happening, then sure, it would've added to the story and been useful, but it served no purpose in the anime and was so unimportant in the manga it was only mentioned in passing. We already cared about Hinami because of what happened to her mother....and seeing what happened to her mother already let us imagine what happened to her father who we knew was killed before the story began, so wasting almost a 1.3 episodes worth of run time on HIM, was pointless because we're not going to care about Hinami any more then we manga readers did already without having to know him, which could've been better spent on Kaneki/Touka (in disguise) visiting the CCG's Ward 20 office (giving the audience some crucial insight into how ghoul's bodies work and exactly what the stakes are for the future of ghouls) that ACTUALLY HAPPENED in the manga. Or the non-existing plot over Jason's pliers, which didn't happen in the manga, because in the manga RC suppressants were used, where as in the anime, since they skipped everything involving how a ghoul's body works, they had to make Quinque steel surgical implements a anime-original plot point, and then wasted even more time on it then just explaining RC would've taken.
Tokyo Ghoul is a rather gritty and Psychological seinen manga, but the animating studio (who are mostly known for shounen series) animated and paced it LIKE a shounen series (the author of the manga is on record as being very disappointed with the direction they took in the adaption), which caused a lot of the explored themes and struggles as to come off as very superficial, with the skeleton of the plot they used serving as just padding to move from action sequence to action sequence, including throwing in new action sequences that never happened or were deliberately never shown in the manga because action was never supposed to be the focus.