A cancer is a cell in the body that "goes bad". It starts replicating itself (dividing) oddly and sometimes becomes a growth or tumour. Sometimes it affects the cells around it and they start replicating incorrectly. Sometimes, it floats off to other parts of the body and then makes those cells start going bad. Eventually, the cancer, because the cells don't behave like normal cells, causes that part of the body to stop functioning the way it was intended. And sometimes, this causes the whole body to die. When this happens, the cancer also dies, because it has relied on the host body for life. But then a cancer cell doesn't think - it just reproduces.
Let's use Lance Armstrong as an example because his fight with cancer is so well known. It started in a testicle but then it spread to his lungs and brain. The doctors cut the cancer out of his testicle and brain but they used chemotherapy to kill the cancer in his lungs. Different location, different cancer cells - different treatment. In his case, the cancer cells died and he lived and the rest is history.
Now, before the terrorist analogy, we need to discuss "society". The cancer cell lives in a human body. The terrorist lives in a society. It's harder to kill off an entire society than it is to kill off one human body but it is possible to try. What does a society need to "live", to prosper? A family is the smallest unit that could be called a society I suppose. A family chooses to live together and there is a certain amount of cooperation so that essentials get done. Same with a country, really. We all live together and cooperate so that certain things get done.
So can a terrorist be likened to a cancer cell? Except for the fact that a terrorist is a whole person and therefore chooses his actions, I think we can. A terrorist doesn't want to live in society with everyone else and acts to destroy the society. It doesn't seem to matter to him that he might destroy himself in the process. And like a cancer, a bunch of terrorists can form their own sort of society (the tumour) -- which is presumably their goal, to form their own society -- but they really can't survive without a properly functioning society off which to feed. Terrorists don't produce anything except other terrorists. They don't make food or shelter or garments or anything really. A body's various parts work together to help the whole thing survive - the lungs bring in and convert oxygen, the blood pumps it and nutrients around, the guts digest nutrients, etc. A society does that too. But a society of terrorists can't survive without a host.
I think we are justified as a functioning society in treating terrorists like a cancer. We have to get rid of them because ultimately, they will kill us and themselves. And even if they don't kill us all (because societies are a lot more resilient than a single human body), they may reduce our society to something that barely functions.
Some societies are more successful than others, if success is rated on a scale of contentment of its members, financial prosperity, tolerance and the ability to leave others alone -- things like that. There is a really great book on what makes a prosperous society called "The Birth of Plenty" and the author posits that you must have Property (private property rights), Reason, Capital, and Communication (transportation, power, light). It is obvious which societies have all four components - North America, Europe, Japan. If terrorists succeed in knocking out parts of the complex machine that make up a successful society, then I think we had better resign ourselves to living much more primitively than we now do. That's not something I want to contemplate.