Colorectal cancer is a common malignant tumor in intestinal tract, the early symptoms are not obvious. Gastric cancer is a malignant tumor originating from the gastric mucosal epithelium. However, the role of MYC and non-SMC condensin II complex subunit G2 (NCAPG2) in colorectal cancer and gastric cancer remains unclear. The colorectal cancer datasets GSE49355 and gastric cancer datasets GSE19826 were downloaded from gene expression omnibus database. Differentially expressed genes (DEGs) were screened and weighted gene co-expression network analysis (WGCNA) was performed. Functional enrichment analysis, gene set enrichment analysis (GSEA) and immune infiltration analysis was performed. Construction and analysis of protein-protein interactions (PPI) network. Survival analysis and comparative toxicogenomics database (CTD) were performed. A heat map of gene expression was drawn. A total of 751 DEGs were obtained. According to the gene ontology (GO) analysis, in Biological process (BP) analysis, they are mainly enriched in cell differentiation, cartilage development, and skeletal development. In cellular component (CC) analysis, they are mainly enriched in the cytoskeleton of muscle cells and actin filaments. In molecular function (MF) analysis, they are mainly concentrated in Rho GTPase binding, DNA binding, and fibronectin binding. In Kyoto encyclopedia of genes and genomes (KEGG) pathway analysis, they are mainly enriched in the MAPK signaling pathway, apoptosis, and cancer pathways. The soft threshold power for WGCNA analysis was set to 9, resulting in the generation of 40 modules. Ultimately, 2 core genes (MYC and NCAPG2) were identified. The heatmap of core gene expression showed high expression of MYC and NCAPG2 in colorectal cancer tissue samples and low expression in normal tissue samples, while they were core molecules in gastric cancer. Survival analysis indicated that MYC and NCAPG2 were risk factors, showing an upregulation trend with increasing risk scores. CTD analysis revealed associations of MYC and NCAPG2 with colorectal cancer, gastric cancer, inflammation, and immune system diseases. MYC and NCAPG2 are highly expressed in colorectal cancer. The higher the expression of MYC and NCAPG2, the worse the prognosis. MYC and NCAPG2 are core molecules in gastric cancer.