Not understanding how the gain works in the 1st stage of an instrumentation amplifier
The output of the first stage is differential. You know the voltage across Rg (V1 - V2), so you know the current. The same current must go through each R1, so you can calculate the voltage scross the three series resistors.
The first stage is essentially differential with ideal op. amps. If you add the same constant voltage to \$V_1\$ and \$V_2\$, \$I_d\$ doesn't change, hence \$V_A - V_B\$ also doesn't change.
\$I_d=\dfrac{(V_1-V_2)}{R_{gain}} = \dfrac{(V_A-V_1)}{R_{1}} = \dfrac{(V_2-V_B)}{R_{1}}\$
The differential gain expression, is the following:
\$V_A = V_1 + I_d \times R_1\$
\$V_B = V_2 - I_d \times R_1\$
\$V_A - V_B = V_1 + I_d \times R_1 - V_2 + I_d \times R_1\$
\$V_A - V_B = V_1 - V_2 + I_d \times (R_1 + R_1)\$
Substituting \$I_d\$:
\$V_A - V_B = (V_1 - V_2) + \dfrac{(V_1 - V_2)}{R_{gain}} \times (R_1 + R_1)\$
\$\dfrac{(V_A - V_B)}{(V_1 - V_2)} = 1 + \dfrac{2 \times R_1}{R_{gain}}\$
I have added a couple of measurement points for clarity
The input amplifiers operate as non-inverting devices. Provided the inputs are within the common mode range, then the voltage (by feedback) at point C will be the same as at V1.
Note that for an instrumentation amplifier, the common mode range is a bit more involved.
The voltage at point D will be the same as V2.
Therefore there is a voltage across Rg of V1 - V2 assuming V1 is the more positive input; i.e. the input differential voltage.
Therefore a current flows through Rg of \$ I_{Rg} = \frac {V1 - V2} {Rg}\$.
Assuming no current into the inverting inputs of the amplifiers then this same current flows in both the R1 objects, then the voltage between points A and B must be \$I_{Rg} (2_{R1} + R_g)\$
So the actual voltage at points A and B (expanding back out) is \$(V1-V2)(1+\frac {2_{R1}} {R_g})\$
As the gain is given by \$\frac {V_{AB}} {V_{CD}}\$ then by factoring we yield \$G = 1+ \frac {2_{R1}} {R_g}\$