That's a rather general question so here's a rather general answer.
The defense deploys on a particular play as it has practiced vs. offensive formations. That's why coaches will say 'we didn't line up right' or 'we had a guy out of position' when there are questions about a huge offensive play.
There is no perfect defense because every contingency can't be fully covered on every play/formation so the defensive coach must mitigate or mask their team's deficiency and play the percentages. IOW, hours of film study and charting the opposing offensive team's tendencies will give the defensive coach an idea of what the offense is attempting to do on a particular play. He then would take into consideration the down and distance, score of the game, time left in the half and even the conditions of the day when making his defensive calls or adjustments.