I was always under the impression that if the defender plays the ball in an attempt to stop if from getting to an attacker who was in an offside position, then it's called offside because the offside player still influenced the play. I must admit I've never read the official rules, it just seems to get called that way.