Genetic variants, "genetic defects" is a bit too harsh I feel. These NOD2 and ATG16L1 variants specific to crohn's disease (not UC), confer a certain disease risk.
But they likely served a function in the past. Mice with Crohn's disease NOD2 variants survive when challenged with certain Yersinia strains while NOD2 "competent" mice do not. In Europe, Crohn's disease NOD2 variants are most common in geographic regions that suffered from plague outbreaks (yersinia pestis), suggesting that these genetic differences were an evolutionary necessity, and crohn's disease in some individuals might be a cost one pays.
The positive news is that these variants do not seem to lead to autoimmunity like some suggested in the past. They're not leading to self-reactive immune cells that target our own cells.
Factors in our control can influence the course of the disease. Put crohn's disease patients on EN for 4 weeks and inflammation goes away completely in the large majority of patients. This does not work with UC at all, where the case for autoimmunity is much stronger.
Immune function of crohn's disease patients seems generally fine, the innate response seems just somehwat delayed and macrophage function is suboptimal. You can only really see these genetic variants at play when you look at neutrophil recruitment, and it just so happens that the intestine is rich in phagocytes so any macrophage reaction that isn't optimal will be magnified in the intestine. But it's not like our immune system is defective, infections do not seem more common in crohn's disease patients when adjusted for medication, intestinal macrophages of crohn's disease can kill common foodborne pathogens. And while certain bacteria (like AIEC and other pathogens) can exploit autophagy incompetence of macrophages associated with some of these CD variants, given the right conditions, people do go into remission, one assumes CD patients can very likely control and kill these pathogens. They exploit inflammatory conditions that lead to a breakdown of intestinal barriers and invade tissue or peyer's patches.
Crohn's disease is receptive to diets like EN, and is likely going to be receptive to treatments that can decrease bacterial and fungal load in the future. The prospects for UC are not that great compared to those for crohn's disease. The use of IBD in articles is unfortunate, very different diseases.