Part of the reason cancer is such an interesting field of study in my personal opinion is:
(1) You get a lot of these chicken-or-egg situations where the answer is more like "chicken-AND-egg".
(2) Cancer is almost always the result of a million things going wrong at once... it's a slow unravelling of the bonkers number of safe-guards our cells have to keep them healthy and normal.
Inflammation is a normal part of a healthy, functioning body. It can be caused by anything from scraping your knee to getting a cold. It's useful, and as your comment says, it is an important part to fighting off infections which themselves in rare cases cause cancer. It also plays a pathological role in some diseased like auto-immune disorders, IBS, meningitis, etc...
Inflammation, both the healthy and pathological sort, can help set the stage for tumour to form by contributing to the formation of what's known as a "tumour microenvironment" [0]. Chronic inflammation, often caused by disease, is more likely to keep up this permissive environment than one-off cases, and therefore more likely to result in a tumour
By the way, we understand DNA mutation/damage to work similarly. It happens all the time naturally, and sometimes mutations are fortuitous, but mostly they are ironed out by the cells machinery. Increasing the rate of mutation can overwhelm that machinery and cause tumours to snowball.
So, that's how inflammation can contribute to the initialization of tumours or at least environments that are more permissive of tumours. Tumours, however, also might cause inflammatory response to promote cancer progression through hijacking cell signalling, promoting epithelial-mesenchymal transitions, etc... [1].
We've known inflammation has been linked to cancer since at least 1863 [2], so this is pretty well-trodden territory. The immune system and inflammation is extremely complicated (or at least, I always found it to be), so I'm also not surprised that there are a lot of mysteries lurking.
Finally, to answer your question: I'm sure in some cases inflammation is just bystander. My understanding is that inflammation is not the primary mechanism by which HPV causes cancer, so it is very easy to believe it to be a bystander in that case. H. pylori is a good example of chronic GI inflammation that raises your risk of cancer by way of inflammation. I'm not familiar with the fungal DNA research, so can't comment.
Also disclaimer: It's been a while since I've studied cancer directly, I'm more of a computational biologist these days. Sorry if I made an error here.
[0] https://pmc.ncbi.nlm.nih.gov/articles/PMC6831096/
[1] https://blog.cellsignal.com/hallmarks-of-cancer-tumor-promot...
[2] https://www.thelancet.com/journals/lancet/article/PIIS0140-6...