My first teacher, who could "see" people's karmic roots of their present conditions (including diseases), often explained cancer-type diseases. While he never gave one summary "rule" to map diseases to karmic roots - and was actually offended when I proposed that to him - I can try and summarize some of the main points here, and hope that they can be of more help than harm due to overgeneralization.
In case of this answer, unlike with some other answers I give, I don't claim to see these things directly by myself - so this is only my attempt to explain main points of what I received as conceptual teaching:
- In general, physical diseases - just like most other types of troubles according to Buddhism - come from attachments. More often than not these attachments are subtle ones, like attachments to certain principle or a view system - not obvious/superficial attachments to a person or thing.
- Many times (but not always) I heard cancer-types diseases explained through attachment to spirituality. In this context "spirituality" should be understood in general as orientation towards the high ideals of outworldliness and away from the lowly values of this world. My teacher emphasized that spirituality, intellect, principles, etc. should not be placed above the genuine nondual love (as a first approximation of bodhicitta).
- As I understand, the person in this condition (again, I don't want to overgeneralize, but this seemed to be the gist of many of those cases) may actually be very selfless and noble - while at the same time projecting very strong contrast between him/her and the world or the corrupt society, which colored their attitude to life as a whole - not necessarily in a negative way but certainly in a way that made them somewhat isolated mentally or emotionally.
- This coloration of experience / the feeling of isolation then supposedly creates certain hormonal dis-balance that could lead to certain diseases, cancer-type ones being one of them.
- My teacher emphasized that spirituality, intellect, principles, etc. should not be placed above the genuine nondual love (as a first approximation of bodhicitta).
In theory, if above is indeed the case, the healing is always possible through a deep change of one's perspective on life. However, because karma is very inertial it may work better on early stages - and on the later stages the person may simply not have enough time left to transform themselves.
I apologize if this offends anyone by putting the responsibility for the disease on the bearer of it, and I don't want this to seem like the only possible explanation - there are many types of and many objective causes of cancer. But this is what I was told, as much as I can remember it in a very simplified form, so I'm sharing it in the hope that it will help someone to prevent cancer, if not to heal it.