The renderer can't know the two calls to Camera.Render are connected and allocates a different depth buffer. This is not the case with the main scene as the engine knows all the cameras before rendering and assigns them to the same stack.
A possible workaround is as follows
1) Create new render texture asset in the project
2) Duplicate First & second cam and set them up in the inspector to render to the render texture from (1)
3) Assing the render texture from (1) to the RawImage canvas object
Similar set-up can be achieved from script. Setting it up this way means unity will automatically set up the two cameras as part of a stack and render correctly to them every frame as part of the main update loop. This also doesn't need a script.
I hope this helps.