The defensive points allowed setting will deduct points from a team defense any time the opposing offense scores a point.
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.
What about kick and punt return TDs?
By default, these do not count against your DEF, but you can adjust them to do so by entering values in the Special Teams Defense scoring section of your settings.