Immune cell mechanisms in cancer and infection