It's radiation damage to the rectum as a result of treating the prostate.
There are different types of damage, and they also fall into short-term, and late-onset.
The bowel ordinarily produces just enough mucus to lubricate stools exiting, which you don't normally notice. The excess mucus is the bowel wall's response to being irritated, which it assumes to be a toxin, bacteria, or virus, and the mucus is to try and wash it out (and diarrhea for the same reason). In this case, it's the radiation causing irritation, but the bowel behaves the same way, not having evolved a specific radiation response. This usually starts during the radiotherapy, and then diminishes slowly afterwards. My oncologist refers to it as "mucus farts", and another oncologist used the phrase, "an over abundance of rectum lube". For me, it was gone by about 10 months after radiotherapy, after which farting was safe again. This duration varies enormously from one person to another though. Actually, even after this I could tell there was still more rectum lube than before, because it makes taking a dump easier than it was before treatment! I mentioned this at a support meeting, and there were several agreements among other members, so I know that's not just me! I think at 16 months post treatment, rectum lube may be completely back to normal now.
You may also get some broken blood vessels, causing rectal bleeding during and just after radiotherapy, and due to soreness from diarrhea.
Then you may get some late-onset side effects, usually starting at least 6 months after treatment, but can be 5 or more years too.
Rectal bleeding is probably the most common. The radiation and healing cycles cause fibrosis of blood vessels, and they become fragile. Some time later, they break and bleed. Usually this is minor and goes away by itself, although you do need checking to make sure it's not bowel cancer. Sometimes it can be major, causing either incontinence, pain, unsafe bloody farts, or anemia, and then it needs treating. There are things that can help with this, but no sure fire way of fixing it. I have some minor painless rectal bleeding, which causes me no quality of life issues at the moment. After COVID, I'll look to get referred for it, but I had a clean bowel screening just before being diagnosed with prostate cancer, so I can probably rule that out. Otherwise, getting it checked out would be more urgent.
As a late side effect, I'm not sure what would cause mucus farts, but it's not difficult to imagine some permanent damage irritating the bowel wall, causing the over abundance of rectum lube.
Another late-onset impact from fibrosis of blood vessels can be erectile dysfunction. There are similar size blood vessels supplying the penis, and they can suffer from fibrosis and failure in the same time frame. (Unlike prostatectomy, ED is not normally caused by nerve damage in the case of radiotherapy, although that's not impossible in rare cases.)