Mostly you see everyone says to join two objects or Ctrl + J. But by using this method two objects will not be merged completely they stay two objects. So what is the solution?
In this case, we want to merge these two cubes.
We do not use the Join method. We use the boolean modifier. Add a boolean modifier to the first cube.
So after you add the boolean modifier select the second cube to the Object property.
After that, you need to select the Union instead of Difference.
Now apply the modifier, you can use the shortcut Ctrl + A
Now delete the second cube.
Select the first cube and go to Edit Mode. And you will get a result like this:
Now, this is one single object and you can edit it in the way you want.