Affair with married woman

Is having an affair with a married woman illegal for: A) Her lover. (above 18 years age) B) For her. (above 18 years age) What are the legal consequences and legal risks for both A and B? Do the answers depend on religion or state of domicile or temporary residence? By affair I of course mean a relationship of consent.