The defensive points allowed setting will deduct points from a team defense any time the opposing offense scores a point. There are a few other instances when those points allowed can still be applied.
Items that count toward "points allowed" are:
All FGs scored by an opponent
All PATs (extra points and 2-PT conversions)
All TDs scored against the defense (including TDs from fake punts, returns from kickoff, punts, blocked punts)
So just because the Miami Dolphins defeated the New England Patriots, 27-24, in Week 17 of the 2019 season doesn't mean the Patriots defense had 27 points allowed.
In fact, using that example, the Patriots DEF only had 21 points allowed. This is because Tom Brady threw an interception that was returned for a touchdown. Since the Patriots defensive unit was not on the field, it does not count against the defense.
However, the DEF is always held accountable for extra points or 2-point conversions, even if they didn't allow the preceding touchdown. There isn't a way to change that.