Why would the player fail to achieve their intent on a successful roll? That seems contrary to the spirit of the rules (at least for 5e) and would frustrate players to no end. In other words, the roll is not to see if the task alone succeeds, it's to see if the task achieves the intent. In trying to make your point, I think you've unintentionally conflated two intents/goals here: hit the tree, distract the guard. I think that's the point
@Reynard is making.
So, really, the outcome you've just described in the given scenario is the player
failing the roll for their PC to distract the guard (intent or goal) by throwing the rock at a tree (task or approach). Task and intent
are both integral parts of the action declaration of the player as
@Charlaquin succinctly describes above.
On a failed roll, the GM could then describe the outcome any way they want. Maybe the rock missed the tree entirely. Or, as the case may be as you described, sure the rock hit the tree but it didn't automatically distract the guard b/c... reasons. The GM can come up with anything that makes sense in the fiction based on the results of the dice. Now the players have a new set of circumstances to deal with: "rock hits tree, guard may or may not have noticed but is acting unfazed, what do you do next?"