Your symptoms are more consistent with prostatitis than prostate cancer.
Prostatitis is mostly not bacterial, although the fact yours went and didn't come back after a course of antibiotics suggests it might have been.
However, I think I would ask for a referral to urology given it's happened again, and they might consider doing an MRI scan, and better investigate the cause.
Prostate cancer usually has no symptoms, although of course it can coexist with prostatitis or enlarged prostate.