This can simply be achieved by making sure that their base-emitter
voltage is the same.
Not quite. The collector current can be written as
$$I_C = \beta_0\left(1 + \frac{V_{CB}}{V_A}\right)I_B$$
and so depends on the base current and the collector-base voltage (Early effect). Connecting the collector and base together $(V_{CB}=0)$ removes this dependence on the collector-base voltage and the relationship simplifies to
$$I_C = \beta_0 I_B$$
Since $V_{BE1} = V_{BE2}$, the base currents are equal (assuming identical transistors etc.) and so we can then write
$$I_{REF} \equiv \frac{V_{DD} - V_{BE1}}{R_1} = I_{C1} + I_{B1} + I_{B2} = I_{B2}\left(2 + \beta_0\right)$$
and it follows that
$$I_{C2}=I_{REF}\frac{\beta_0}{2 + \beta_0}\left(1 + \frac{V_{CB2}}{V_A}\right) $$
If, on the other hand, $V_{CB1} \ne 0$ (for example, place a resistor between the collector and base of Q1 rather than a wire), the equation relating $I_{C2}$ to $I_{REF}$ is more complicated
$$I_{REF} \equiv \frac{V_{DD} - V_{BE1} - V_{CB1}}{R_1}$$
$$I_{C2}=I_{REF}\frac{\beta_0\left(1 + \frac{V_{CB2}}{V_A}\right)}{2 + \beta_0\left(1 + \frac{V_{CB1}}{V_A}\right)}$$