Merging objects with flush faces, using Boolean union modifier? Apologies if this is a question that's asked a lot from beginners,

I am trying to connect two objects with flush, overlapping faces, and it seems that the union boolean modifier does not handle these "edge" cases. The resulting mesh has internal faces and other artifacts. But if I move the mesh, so the faces are not overlapping then the union works as intended. I briefly looked this up and if I understand correctly, the boolean modifier is not meant to handle my particular case?

Here is a picture to illustrate what I intend to do:



Is there a way to easily merge these two together in a way that results in a "clean" mesh?

I plan on merging many modular pieces together many time over, so any method that involves manual work is not very suitable for me; I'm hoping there is something  that behaves like the boolean-union modifier, and can perform the operation on "flush" object intersections.
I am new in Blender and I was facing the same problem a few days ago, so here is what I did:
One way that solved the &quot;intersection's anomaly&quot; was the Bool Tool addon. After you add this, you can use the shortcut Shift + Ctrl + B  and the Bool Tool options will pop up.
The Bool Tool did not create any issue for me after the union.
Using the Boolean Modifier:
When the union is done, even though you get the anomaly, apply the modifier. Then, in your Collection list you can see that the mesh you tried to merge to your other mesh, is still there. Delete that mesh. The Boolean modifier managed to merge the two meshes, but the mesh that was merged still exists as an individual object and it's overlapping the final merged mesh you just created, causing the problem.