This is called chaonephora fruit rot. It is most prevalent in wet weather. You can spray a fungicide to protect the developing squashes. It also helps to mulch the soil to prevent spores from splashing onto the fruits. Good air movement to dry the foliage and fruits also helps prevent the disease.