(I accidentally added this as a comment, sorry!)
Extending something in this case means that it's growing taller or longer. It's about height. Extending means that it's getting bigger in one direction.
Expanding means that it's getting bigger in several directions, even every direction, like a blob or a balloon. It's about the overall size of an object, not just its height.
Sentence 1: "The pole extended out of the ground." This works because a pole is long and thin, and it's moving in one direction.
Sentence 2: "The balloon expanded as she blew into it." This works because a balloon is growing in every direction.
A pole can't expand, because it can't get wider. A balloon usually doesn't extend, because it spreads in many directions, not just one. :)