It’s because the play happened. If it was whistled dead before the play, then it’s a 5 yarder. If not, offsetting. Just like when an illegal formation and defensive holding happen in the same play, or really anything other than a false start or neutral zone infraction, the play doesn’t count.