There are good explanations on the Web. I do not think I should copy them here. Please check
怎麼
and
怎麼樣.
In addition, there is a good article (pdf format) published by an associate professor, 蔡維天. I copy the abstract here.
本文的題旨在於討論漢語疑問副詞的一個歧義現象:「怎麼」有時可當成「為甚麼」來用,如「她怎麼沒來?」。這種用法主要出現在助動詞之前,應屬句子頂層結構的一種現象。我們認為此處「怎麼」其實是整個句子的述語,問的是這個句子所表達事件的來由。相較之下,位於助動詞和動詞之間的「怎麼(樣)」則為修飾動詞組的狀語,表一個動作的樣貌或途徑。動詞之後的「怎麼樣」則為整個句子的補語,問的是事件的結果。從本體論的觀點來看,「怎麼」、「怎麼樣」在句法結構上的高低分布正反映出一種因果關係,也就是助動詞前的「怎麼」表「前因」,動詞後的「怎麼樣」表「後果」;中間則夾著表樣貌、途徑的「怎麼(樣)」。若以句法-語意介面的角度觀之,凡此種種不同的語意解釋正是由於「怎麼」、「怎麼樣」所處的句法層次不同,而產生的結果:也就是說,表原因的「怎麼」修飾事件,是整個句子的述語;表結果的「怎麼樣」修飾動作結束後的狀態,是動詞組內的補語;表樣貌、途徑「怎麼(樣)」則修飾動作本身,是動詞組的狀語,而和主語的主體意識(agentivity)相關。此外,表原因的「怎麼」在句法上的分布也和「為甚麼」相當一致,可採「無擇約束」(unselective binding)及「相對性近距原則」(relativized minimality)等概念加以規範。
The aim of this paper is to examine an ambiguity of Chinese wh-adverbs:
zenme ‘how’ is sometimes construed as causal rather than method or manner,
as in Ta zenme mei lai?‘Why didn’t she come?’ We show that causal zenme
typically appears before modals, behaving very much like a matrix predicate.
By contrast, its postmodal counterparts are interpreted as method or manner
preverbally, and as result postverbally. From the viewpoint of ontology, the
structural distribution of zenme(yang)embodies a “cause-effect” relation, and
in-between, we have agent-sensitive concepts such as method and manner. In
terms of the syntax-semantics interface, it is demonstrated that the various
interpretations of zenme(yang)are conditioned by the syntactic projections it
occurs in. Namely, premodal zenme takes the whole sentence as its comple-
ment, which corresponds to an event. This results in the causal reading.
Postverbal zenmeyang, on the other hand, serves as a complement to VP,
corresponding to a resultant state. Hence the resultative reading. Furthermore,
when method/manner zenme(yang)serves as a VP-adverbial, it modifies an
action, thus sensitive to subject agentivity. Finally, we find that causal zenme
actually patterns with weishenme ‘why’ with respect to their syntactic behav-
ior, which can be accounted for by adopting the notion of unselective binding
and relativized minimality.