In the context of cancer, leukocytosis can occur due to several reasons. Certain cancers, particularly hematologic cancers like leukemia and lymphoma, directly affect the production and function of white blood cells. Solid tumors can also cause leukocytosis through the production of growth factors or cytokines that stimulate WBC production. Additionally, inflammation and infection secondary to cancer can contribute to elevated WBC counts.