Contraceptive pill 'can protect against certain cancer types'