Cancer can be idiopathic - unknown reasons for developing or familial/hereditary.
Most cancer cells develop under certain conditions but the number one known contributor is Stress.
Prolonged stress promotes oxidation of the cellular proteins, which makes these cells mutate, forming into cancer cells. Increased stress suppresses the body's immune system, further providing a good environment for the cancer cells to mutate and metastasize or branch out from their focal point of invasion.
Hope this helps. :)