You do realized that her false testimony pushed him to admit to regicide when he was innocent, putting him on deathrow in the end. She deliberately falsified her claims to get him convicted of regicide, that is attempting to kill him. Now grabbing a knife because you feel in immediate danger (by an unarmed little person who is shocked to see you in his father's bed) is totally reasonable and I did not dispute that. I am sure rage got the better of him and that is why he killed her in the end.
I do sympathize for him though, he did love her and was betrayed by her which broke his heart. Then seeing that she was sleeping with his dad. Yeah that sucks for anyone in tyrion's shoes both in GoT and in real life. That doesn't excuse his murder but its why I feel bad for the poor dude. Then to kill the one he loved, whether by self defense or intentional doesnt matter, it just sucks. I wouldn't wish even my worse enemy to be in tyrion's shoes. Hell if I was in his shoes I'd likely end up killing myself shortly after.
Now why he didn't just run away? No idea. Perhaps he went to his father's chambers initially to get some answers, maybe he intended to kill Tywin. The TV doesn't really shed light on why he went back (though the books from what I hear gave him a good reason to go find his father). I am sure he didn't intend to find Shae there, nor to see her harmed. He just stood there, staring dumbfounded at her.
The "I'm Sorry" doesn't mean its okay to murder someone, it just shows that he regrets what he did. Again it doesn't excuse it, he wept for her because he did love her. It makes their arc together since season one all the more tragic.
I remember watching the murder scene and just felt terrible for the both of them. The show makes it seem like jealousy and the break up drove her to betray him. Her heart broken too.

As the author of these books has said, no one in the books/show is wholly a good guy or a bad guy. Some have elements of mostly good, some have elements of mostly bad. Nearly every major character has done something bad in the show so far. Tyrion was seen as the "good guy" for a long time. But after all this crap has flown his way, it broke him and made the more terrible aspect of his character come to life. Killing his father, murdering his lover, leaving the only world he ever knew, and saying farewell to the only family member he truly cared for. All in the span of 15 minutes or so. I think that's what makes GoT so believable. Their world is an ugly place, just like ours.
