@Liana If you paid attention to the story and the surroundings in DA:O and ever had Loghain in your party --which I assume you never had-- you would have your questions answered already. So I'll go and explain it to you in full detail, and why I don't consider Loghain an evil character, per see.
And there's a reason to why he did it. Loghain was always fighting Orlais, and never considered the darkspawn attacks more then a very large raid. No way that would he risk the strength of his army, in a battle against an opponent that proved stronger then expected, when the real threat was an army of chevaliers at his doorstep. He was certain that inviting the forces of Orlais would result in another war, as fighting the darkspawn would weaken Fereldens forces, and by then the enemy would already be in the country – and he’d be back fighting for freedom again – thanks to the foolish king.
I’m not saying that the outcome was the best when Loghain chose to withdraw from Ostagar, but I do understand why he did so. It was, at best, a battle that would weaken him enough that he’d never be able to fend of the real threat: Orlais. And what use would defeating the darkspawn raid (as he never believed it to be a Blight) have if they would be conquered by the Orlesians again? So he retreated, and went on to expel the Orlesians before they crossed the border – securing his country from the real threat, at least in his mind. And as he must have expected that he might have to withdrawn, he had made preparations to ensure that the possible civil war would be as brief as possible – that way he could get back to the task of dealing with the darkspawn raid before they did too much damage.
And as Loghain said himself about Cailan's death, it was his own doing. Cailan was a naive king that wanted to play war and save the world just like in the old tales he had read of. This lead to him trusting too much on the Wardens which lead to his own death. Loghain even insisted that Cailan shouldn't be on the front lines with them, though he wouldn't listen. And the minute Cailan made his strategy clear: rely on the Grey Wardens to win the day, Loghain knew how it would end for Cailan. Though IMO, Loghain still wasn't certain that he would walk away --and if he thought that riding into the valley could have won the battle, he probably would have done so. Whether his belief that this couldn't happen was the truth or just his twisted perception of it is something you can decide for yourself.
And I might also add that Loghain once made a promise to Maric that he would never allow one man to be more important than the Kingdom -- and in his eyes Cailan was recklessly endangering both himself and his kingdom during Ostagar.
"So Loghain was prepared to ditch Cailan but didn't necessarily want to? What as he then hoping to accomplish?" you might ask. I think Loghain was hoping that Cailan would see reason. He didn't expect him to, but was hoping he would.
And as for sacrifing the people at Ostagar, you do remember that most of them were Grey Wardens? And I hope you do know that he did not trust them, especially when most of the men were from Orlais. yeah, I don't really judge his decision b/c of his experiences with them in 'The Calling'. The book is about what led up to King Maric allowing the Wardens back in to Ferelden. So long story short, Maric goes off with some Wardens on a rescue mission without telling Loghain. In the meantime there is an attempt by Orlesians, in cooperation with the Architect to take over Ferelden's Circle Tower and eventually Ferelden I guess (I should explain, this wasn't the Orlesian government, it was the Orlesian First Enchanter of Ferelden's tower, some Orlesian troops, and a couple Wardens- the Architect had a plan to taint all humanity in order to stop the cycle of Blights). Loghain shows up with troops to repel this plot and rescue Maric. So he does have more reason than most to mistrust Wardens.
And as for sacrifing the "none wardens" during Ostagar, this (and little of why he didn't rescue Cailan) can mostly be explained in the party banter between him and Wynne:
It's not like he returned to Denerim from Ostagar and said "Right, I shall now start a demoralizing and resource-sapping civil war as part of my evil plot of evilness, mwahaha." Actually his intention was to unite the country in its time of crisis, and to do it as quickly as possible, choosing his daughter as the most capable (and reigning) Queen and himself as the best man for the job of reorganizing the available resources for defense against the Darkspawn and, yes, the Orlesians. The civil war happened because (A) the Banns didn't take kindly to being ordered about by a commoner as though he were their commanding officer, ( he failed to recognize that the Banns weren't his soldiers and wouldn't just follow orders, nor respond favorably to being punished for insubordination, and © a couple of surviving Grey Wardens were roaming the country making incendiary pests of themselves and giving the already-discontented Banns another banner behind which to rally.
Again, you could debate the actual size of the Orlesian threat or the ill-considered manner in which Loghain chose to conduct himself, but to say "he started a civil war" would be an error.
So what? The only evidence we have that they sided together before the battle is the suspicions of the self-admittedly prejudiced Wynne. That is not evidence at all.
What we do know is that Loghain made an alliance with Uldred in hopes that he'd have Ferelden's best weapon at his side. Uldred first tried to peacefully convince the council to join Loghain, and then Wynne showed up. At that point she was rather convinced that Loghain betrayed the King at Ostagar. Unfortunately here we only have the testimony of the half-asleep Niall, who displayed the virtues of the Isolationist fraternity by ignoring the rest of the world. What he does seem to recall vaguely is that Uldred started making what he thought excuses for Loghain's actions, and only after Uldred unleashed an attack on the room did he wake up from his day-dreaming. We already know that Uldred was a vocal proponent of mage freedoms and given how many Blood Mages he had on his side, it's likely that he already had supporters waiting for his signal. The battle turned against Uldred and in a panic he summoned the pride demon . . .
. . . yet none of that involved Loghain. All we know is that Loghain made an alliance with Uldred to gain the support of the mages, before or after the battle is not known. It's pure conjecture to state for a fact that they made their alliance beforehand, and rather underhanded to use an assumption, Loghain's "evilry", as proof for it.
This was done in anticipation that Loghain and Cailan would have a showdown, and Arl Eamon would always solidly be in Cailan's camp. And as you might know, Loghain is the sort of man that will ensure his enemies are defeated before they're engaged.
And you might be interested in a post by David Gaider himself on the official Bioware's forum.
This is a real crime that Loghain has committed. But there's a "good" reason to it.
If the orleasians or darkspawns should've ever attacked Denerim, the Alliange would have been utterly destroyed along with the elves, who would have had no weapons to defend themselves. This way Loghain "saves" their lives by sellling them as slaves away from Ferelden, and getting money to fund his army with weapons and armor. Kind of brilliant IMO.
Howe acted on a great number of things without Loghain's involvement or approval. He's the one to accuse, not Loghain.