In a more general sense, morals are present throughout social animals. For instance, wolves will not generally kill and eat their own pack. This has an obvious advantage for the wolves as hunting in a pack gives them a survival advantage, but it is effectively a moral code.
As for the specific example of rape, I can explain a logical progression from very simple survival pressures. For instance:
Primates survive much more effectively in groups, especially humans which lack physical prowess but make up for it in ingenuity and cooperative ability. Thus, "Don't kill members of the tribe" would in general be a behavior that is encouraged through natural selection. It is also obviously in the best interests of males to protect the females they impregnate from other males, and we can see this through many different species.
The progression comes about when these two imperatives are combined; it is necessary for males to protect their females while also not permitted to kill each other in pursuit of that goal. Males would then tend to split off the females into mating groups with poaching of other's groups viewed as unacceptable; if a male poaches another's mate, it is viewed as a threat by males as-yet unaffected. It is sort of like a deer seeing another deer eaten by a leopard, the extension of the concept to itself is not hard.
Now you ask why rape and polygamy isn't accepted by society? Well... the truth is that you are viewing the issue from a tiny data set of your particular society. Even in the US it has only been a few hundred years since women were considered to be "owned" by their husbands, if that long. In the 'Middle East' it is still widely socially acceptable for males to have many wives, and to have sex with them regardless of their feelings. Fathers regularly consider marriage as giving their daughters to another man, rather than the woman making a choice that is her right; ever hear of a dowry? The modern American culture still expects the suitor to ask the bride's father for her hand in marriage, as that was where the real decision was made.
So, in answer to your original question I would have to say that the contradiction is hardly present in the quantity that you would like to believe. We still act much like other animals, even in what we would consider civilized society. The fact that we now consider rape wrong would, in my opinion, be an extension of the empathy with our own that our intelligence allows. By considering women as beings with their own rights, feelings, and goals we respect their choice of mate. Is this so different from a monkey not stealing another fellow monkey's food? I think not.