In football; after an attack on goal, the goalkeeper gains possession. An attacking player quietly remains behind the goalkeeper in hopes to be forgotten. The goalkeeper drops the ball to feet in order to play (not having noticed the attacker loitering behind). The attacker springs to action and steals the ball and knocks home a goal. The player is not considered offside. What rule allows this play to continue? It seems counter to the offside rule or could be labeled as trickery?
Further, in a recent match, a player 10 yards offside received a glancing ball off a defender's attempted clearance header and hit one home. What is the correct ruling? Thanks.