why wavelet coefficients are zeros after decomposition
If you recall, db1 is the Haar Wavelet.  The Haar Wavelet takes either an average of pixels within local windows for the approximation coefficients (or the LL band), or a difference of pixels within local windows for the detail coefficients (or the LH, HL and HH bands).  

Be advised that the input image that you specified only consists of two intensities: 0 and 255.  Also, you set a square grid within this image to be 255 and it is uniformly shaped.  

For self-containment, this is what your test image looks like:



This uniformly shaped object within a square image is important as part of the reasoning why you are not getting any output for the detail images (HL, LH, and HH).

The best way to describe why you're seeing an output for db2 and not db1 can be shown visually.

This slide is from the University of Toronto's CS 320: Introduction to Visual Computing course, specifically, the Discrete Wavelet Transform lecture:



You are well aware that when you take the 2D DWT, you produce 4 sub-images that are half the resolution of the original image.  The first output of dwt2 are the approximation coefficients where each output pixel is an average of a 2 x 2 window.  The other outputs (second, third and fourth) are detail windows that take two pixels within the window and subtracts these with two other pixels in the window.  

As such, the reason why you are not getting an output with db1 is because all of your calculations for the detail images will cancel out.  Specifically, you will get 2 x 2 windows of either completely 0, or completely 255, and when you calculate the detail images, you will get 0s for the output regardless.  You would take add two 0 values, or two 255 values and you would subtract these with two other 0 values, or two other 255 values respectively, thus causing the output to be 0 regardless.

The db2 wavelet is a more complicated transform which is a weighted sum of non-uniform coefficients and so you will certainly get outputs for the detail images rather than just a simple differencing of the 2 x 2 windows.

I would like to stress that if you have a more complicated shape that is non-uniform, db1 will certainly not give you a zero output.  Try it on any test image that comes with MATLAB, like with cameraman.tif.



Hope this helps!