The purpose of semen is reproduction, it is important. Therefore, to release semen in such a way that reproduction cannot result is bad and if it is done by choice, it is a sin. This addresses masturbation as well as unnatural sexual practices, withdrawl and condoms (since the semen does not actually at any point enter the woman, reproduction cannot result). Contraception, depending on which method is uses, also violates other principles of Natural Law.
For instance, there is a principle of Natural Law that states that beings like remaining how they are. I don’t want to chop off my arm because I’m better with my arm and unless someone is mentally ill, they don’t want to chop off their own arm either. For me to lose my arm is an objective evil, it could happen in an industrial accident (in which case it would just be an accident, no sin) or I could cut off my arm or someone could attack me and cut off my arm (in these cases, it is deliberate and there is no good reason, therefore it is sinful). But if I mangled my arm in a piece of machinery and a surgeon had to amputate it, lest I die from infection, then it is okay (the whole is greater than its parts).
Losing a function of the soul (the soul is the life-principle that makes the difference between a corpse and a living person) is an objective evil. So to
deliberately block a morally-significant function of the soul without sufficient reason is sinful. This goes from getting drunk (restricting/blocking the use of reason) to sterilization or hormonal contraception (blocking the use of the reproductive ability). There are justifying reasons why someone could get drunk (say, someone has to amputate my arm in an emergency and there is no anesthesia but there is a handy bottle of rum) and there are justifying reasons why someone could be sterilized (e.g. removing uterine or ovarian cancer). The whole is greater than the parts, it is better for me to get drunk than to be in agony and die of shock amputating my arm without anesthesia, it is better for me to have a hysterectomy than die of uterine cancer.
So we cannot do anything which is either an act which does not lead to reproduction or do anything to actively attack our reproductive abilities (which is like cutting off our own arm – it is self-mutilation if there is not sufficient reason, like cancer). So this eliminates all forms of contraception.
It is however, not illicit to have marital relations if a woman is naturally not fertile. Perhaps she is entirely unable to have children, perhaps she is too old (although Hannah and Elizabeth are good counter-examples!) or perhaps she is just at that point in her monthly cycle where she is not very likely to conceive.
The very basic way a woman can check to see how likely she is to conceive is by counting the days since her period started. This is called the
rhythm method. A more sophisticated approach involves charts, ovarian tests (which look like pregnancy tests) and temperature readings to draw a complicated picture of fertility. This system can be used when a woman is
trying to get pregnant (so she and her husband can focus on those days) or when she is trying
not to get pregnant (so she and her husband can avoid those days). This is called “Natural Family Planning” (NFP).
However, that doesn’t mean a couple can just avoid having marital relations to avoid having children for any reason, the purpose of marriage is to have and raise children. Indeed if one or both spouses have no intention of having children at all when they are married, the wedding is invalid and they are not really married (although alleged [putative] marriages are considered valid until shown otherwise, so no worries). The couple even has a debt to pay to society to have children, if possible, so purposefully avoiding having children requires a sufficiently grave reason to do so (just like I can’t cut off my arm unless I have a good reason – “I just felt like it one day” doesn’t count). So if a woman is at a high risk of complications if she gets pregnant, including that she may die, it is okay to abstain from marital relations even for the remainder of the marriage. Or the husband might be out of work or underemployed and another mouth to feed could put them all out on the street. Or they are living in China and the Chinese government will murder their child if they have more than one. Thus there are legitimate reasons people have to avoid having (more) children. But even if they have a legitimate reason, they can only avoid having children by abstaining from marital relations during the more fertile times and not through unnatural sex or contraception.
I hope this clears things up.