Certified GKH Gardening Expert
It looks like there are rotten parts on the cactus, which have turned almost black or grey and are probably mushy. Has it been exposed to any harsh weather conditions, like freezing, excess heat, or very strong sun? It also looks like there may be a few wounds about halfway up where fungi could have entered. Root rot caused by overwatering or by contaminated soil can also be a cause.
Check whether the cactus feels mushy all along its height- if there are any non-mushy parts near the bottom that are still green, you may be able to cut the cactus down to that point to remove the diseased portions.
https://www.gardeningknowhow.com/ornamental/cacti-succulents/scgen/cactus-going-soft.htm
Thank you so much Alisma! I'm sorry it's taken me awhile to respond. I did cut off the top of the cactus and moved it to a place I thought it wouldn't get much rain, but I had to move it a second time andit looks like it is surviving so far :)