Let's see... I'm in a poor country and I'm invaded by a vastly richer country. I have some prisoners, but they cost me resources to house and feed them that could be directed to my fighting forces. I'm probably going to lose anyway and I can't see the possibility of a prisoner exchange as being necessary. What to do? What to do?
From an economic, logistic and nationalistic perspective, it makes perfect sense to simply put a bullet in their heads.
Certainly, we can add the morality spin to it... it's a good motivational tool, but that's about it. War is hell. Get used to it.