I'm not totally sure but I think when a plant is harvested too late the THC turns to CBN. Or when it's cooked too much.
CBD on the other hand is inherent in the type of strain. Genetics.
But let Google tell ya as I'm only about 75% sure in this.