Prince. I have drawn out and attached some of my explanation for you to study. You will note Kirchoff's current law is obeyed.
For the battery in Mesh M2 to influence the current Mesh 1 (and vice versa) the two meshes must share a branch - in this case resistor R where R is not zero.
When R is zero Ohms then the I bar junction in the middle collapses to a point as I have shown. A shared point between M1 and M2 obeys Kirchoffs current law but a shared point connection will not impress any of the electromotive force in Mesh 1 in M2 nor any of the electromotive force of M2 in M1.
You know that Kirchoff's Voltage states that the sum of the emfs in a mesh loop minus the voltage drops in that mesh loop equals zero. This equality for Mesh 1 includes (I1-I2) x R term as it also does for Mesh 2. If R is zero then this term becomes zero.
electromotive forces cause electrons to move to create currents. Thus there needs to be a shared branch of non-zero resistance for the 40V battery's emf to affect the current through the lamp.
It would be instructive for you to work out the mesh currents I1 and I2 for the circuit I have provided in the second attachment using general values R1, R2 and R3, V1 and V2 and assuming the wires are perfect conductors and the batteries have no internal resistance. Then do it for (R1, R2, R3) = (10,20,30) Ohms and (V1, V2) = (10,20)V; then do it again with R3=0 Ohms.
There is of course the case when R is infinite resistance ie: there is no middle branch - this collapses the circuit to one mess and the analysis becomes very easy.