The same genetic component
Cystic fibrosis is caused by a mutation in a gene called the cystic fibrosis transmembrane conductance regulator, also called CFTR gene. That gene is also responsible for the healthy development of many parts of the male urogenital system.
The ejaculatory duct, seminal vesicle, vas deferens, and epididymis are all affected in their development by the CFTR gene. The same mutation that causes cystic fibrosis also causes the vas deferens to be absent in affected people.
It is unknown as to how the mutation causes the vas deferens to fail to develop. It could be that the gene’s code prevents its development, or the lack of development is a side effect of cystic fibrosis disrupting the body’s normal secretions.
There is another mutation in the CFTR gene which causes the vas deferens to fail to develop without any other symptoms of cystic fibrosis.
This absence of the vas deferens is also called congenital bilateral absence of the vas deferens. Basically, the name means that both sides of the organ were missing since before birth. As the vas deferens transports sperm from the epididymis (which itself is a tube that connects the testicles to the vas deferens) to the ejaculatory ducts, if the vas deferens is absent, no sperm can be transported outside the body.
If no sperm get transported outside the male body, he cannot make anyone pregnant. He could have the healthiest sperm in the world but would still be clinically infertile.
Not all men affected by cystic fibrosis produce sperm. This number of completely infertile men is about ten percent of men with cystic fibrosis, so most men still do produce sperm.