TL;DR: Generically$^1$ an action principle gets destroyed if we apply EOMs in the action.
Examples:
This is particularly clear if we try to vary wrt. a dynamical variable that no longer appears in the action after substituting an EOM.
The 1D static model $$V(q)~=~\frac{k}{2}q^2+{\cal O}(q^3), \qquad k~\neq ~0,$$ has a trivial stationary point $q\approx 0$. (We ignore here possible non-trivial stationary points for simplicity.) We can replace the potential $V$ with a new potential $$\tilde{V}(q)~=~a+bq+\frac{c}{2}q^2+{\cal O}(q^3), \qquad \qquad c~\neq ~0,\qquad b~=~0,$$ without changing the trivial stationary point $q\approx 0$. Note that it is crucial that $b=0$, i.e. it only works for a zero-measure set.
For the 2D kinetic term $L=T = \frac{m}{2}\left(\dot{r}^2+r^2\dot{\theta}^2\right)$ in polar coordinates, if we substitute the angular variable $\theta$ with its EOM, the remaining Lagrangian for the radial variable $r$ gets a wrong sign in one of its terms! See e.g. this & this Phys.SE posts for an explanation.
Specifically, we can not derive EFE from OP's action (2).
--
$^1$ The word generically means here generally modulo a zero-measure set of exceptions.