They were not so much moral judgements as practical tribal mores to protect the tribe, imo.
Adultery within the tribe led to all sorts of problems, marriage and child disputes, sexual diseases, fighting amongst members of the tribe, and so on. Southern African tribes also had very strict laws...