You need to assign no data value when you run the gdal_merge using -n nodata_value
. First use a value of 255, if 255 didn't work, then use a value of 0. Other software use a value of 0 as no data value, but for gdal merge it uses 255. You can refer to this answerthis answer as background on this issue.