It's not dumbly random. You need to understand that a one-time occurrence is literally meaningless. You need to understand that what you should be searching for is patterns. Why you don't get this, I have no idea. The best defensive player in the world could still pick up two fouls in two minutes -- the issue is whether this happens with regularity, or is just a one-off occurence.
Def, sp, ath, bl and iq are the areas that impact defense. (And sta indirectly because obviously if a guy is tired, he'll be more prone to defensive lapses, fouls, etc.)