reason why there is two dense layer?
The Convolution layers do the job of feature extracting. Using those feature the DNN layers try to do the classification task. The 512 layer does the job of a feature selector like which feature is relevant for a class or not while last layer is just calculate sigmoid probability.