I've read on Stack Exchange that どうやって can be used to mean "what did you do in order to x"
どうやってお医者になったか? — What did you do in order to become a doctor?
This definition makes a lot of sense to me, but can どうして be used in the same way?
Also, I've heard some people say that どうやって can mean "By what means did you x", exactly like 何で.
Does this mean that the following is valid?
どうやって作文を書いたか — What did you use to write your essay?
Also, besides どうして being able to mean "why", what is the difference between どうやって and どうして?