Heterogeneity is a hallmark of all cancers. Tumor heterogeneity is found at different levels -- interpatient, intrapatient, and intratumor heterogeneity. All of them pose challenges for clinical treatments. The latter two scenarios can also increase the risk of developing drug resistance. Although the existence of tumor heterogeneity has been known for two centuries, a clear understanding of its origin is still elusive, especially at the level of intratumor heterogeneity (ITH). The coexistence of different subpopulations within a single tumor has been shown to play crucial roles during all stages of carcinogenesis. Here, using concepts from evolutionary game theory and public goods game, often invoked in the context of the tragedy of commons, we explore how the interactions among subclone populations influence the establishment of ITH. By using an evolutionary model, which unifies several experimental results in distinct cancer types, we develop quantitative theoretical models for explaining data from {it in vitro} experiments involving pancreatic cancer as well as {it vivo} data in glioblastoma multiforme. Such physical and mathematical models complement experimental studies, and could optimistically also provide new ideas for the design of efficacious therapies for cancer patients.