In writing the Lagrangian of for free motion of a particle in an inertial frame, a key assumption is that the equation of motion must have the same form in every inertial frame. For velocities $\overrightarrow{v}$ and $\overrightarrow{v'}$ in inertial frames $K$ and $K'$, if frame $K'$ is moving with a small velocity $\overrightarrow{\epsilon}$ with resepect to $K$, then $$\overrightarrow{v} = \overrightarrow{v'} + \overrightarrow{\epsilon}\text{,}$$ which is called a Galilean transform. However, because the motion is the same in every inertial frame, the Lagrangians of the free motion of particle $L$ and $L'$ must have the same form in the two inertial farmes, and the said Galilean transform should result in the conversions $$L\leftrightarrow L'\text{.}$$ It is known that the Lagrangain of free motion of a particle in an inertial frame is not dependent on $\overrightarrow{r}$ because the frame is homogeneous, and does not depend on the direction of velocity because the frame is isotropic. This means that the Lagrangians $L$ and $L'$ are only a function of $v^2$ and $v'^2$, respectively, or $L(v^2)$ and $L(v'^2)$. Applying the Galilean transform on $L'$ to obtain $L$, we get $$ \begin{align} L(v^2) &= L'(v^2)\\ &= L'(v'^{2} + 2\overrightarrow{v'}\cdot \overrightarrow{\epsilon} + 2\epsilon^{2})\text{.}\\ \end{align} $$ This can be expanded, assuming small $\overrightarrow{\epsilon}$, with Taylor expansion, whose first two terms, ignoring powers of $\overrightarrow{\epsilon}$ greater than 1, are $$L'(v'^2) + \dfrac{\partial L'}{\partial v'^{2}}(2\overrightarrow{v'}\cdot \overrightarrow{\epsilon})\text{.}$$ The two Lagrangians can only differ by a total time derivative, which is already present in the form of $\overrightarrow{v'}$, and so $\dfrac{\partial L'}{\partial v'^{2}} =\ \text{constant}$. From this we conclude that the Lagrangian is linear in square of speed and $$L = \dfrac{1}{2}mv^2$$.
I don't fully understand:
Why adding a total time derivative does not change the Euler-Lagrange equations. I know it has something to do with the variation principle.
How we can conclude the exact equation $L = \frac{1}{2}mv^2$ from this. Why is the mass included?
Edit
Similar questions like this and this take specific examples to show the equivalence of Lagrangians under Galilean transforms without explaining the underlying variational principle. Further, the similar questions assume a Lagrangian without explaining how to arrive at the final equation from the differential equations.