The immune system responds to cancer cells and virus-infected cells differently. When it comes to virus-infected cells, the immune system typically responds by attacking and destroying the infected cells. This is because the infected cells have foreign proteins on their surface, which the immune system recognizes as being different from the body's own cells.
However, cancer cells are different from virus-infected cells because they are not recognized as foreign by the immune system. This is because cancer cells are the body's own cells that have mutated and grown out of control. As a result, the immune system may not recognize cancer cells as being harmful, and may not attack them in the same way that it would attack virus-infected cells.