A particular diet can reduce the risk of five cancers, including prostate cancer and kidney cancer, a study has found.