The most likely reason Gilbert changes his decision about teaching in Avonlea is D. He truly likes Anne and is humbled when he realizes he hurt her feelings.
This option fits well with the context given in the passage, where it is indicated that Gilbert yearns to make things right and displays a caring attitude towards Anne. His decision to withdraw from the teaching position seems to stem from a desire to put Anne's interests ahead of his own, particularly when he recognizes her feelings and the personal stakes involved.