Cancer can contribute to osteoporosis in multiple ways. Certain cancers, such as breast cancer and prostate cancer, can metastasize to bones, leading to bone loss. Additionally, cancer treatments like chemotherapy, radiation, and hormonal therapy can further exacerbate bone density loss.