How to avoid gap after merging two objects
Left White Mesh. A Cube with loop cuts and one face [extruded] in the z direction.  Thus having the edges you might need to control bevel operation.  Next 2nd White Mesh Selected. Edges selected and the bevel operator used.   These meshes are intended as crude facsimiles of yours.
At this time we think having a fresh start is easier than [join] operator.  Or at least equivalent.
Possible option. 3rd from left Blue image. Faces selected and [Face Dissolve] operator used for a ngon, on both sides. Yellow image on right. Inset faces.