depends on the infection. COVID, for eg, is well-studied as something that chronically weakens the immune system and may cause autoimmune disorders
https://pmc.ncbi.nlm.nih.gov/articles/PMC7744845/
https://pmc.ncbi.nlm.nih.gov/articles/PMC12185401/
so it's not surprising that infections can lead to downstream, systemic problems in the human body which then allows for things like cancer to arise (especially given that we just lived through a once-in-a-century pandemic that is still ongoing)
Has there been a clear epidemiological signal post-COVID in elevations of any cancers? There are obviously stories about elevated rates of e.g. colon cancer in younger people, but those long predate COVID.