The Klein-Gordon equation directly uses a more naive relativistic energy guess of squared.
But since this is quantum mechanics, we feel like making into the "momentum operator", just like in the Schrödinger equation.
But we don't really know how to apply the momentum operator twice, because it is a gradient, so the first application goes from a scalar field to the vector field, and the second one...
So we just cheat and try to use the laplace operator instead because there's some squares on it:
But then, we have to avoid taking the square root to reach a first derivative in time, because we don't know how to take the square root of that operator expression.
So the Klein-Gordon equation just takes the approach of using this squared Hamiltonian instead.
Since it is a Hamiltonian, and comparing it to the Schrödinger equation which looks like:taking the Hamiltonian twice leads to:
We can contrast this with the Dirac equation, which instead attempts to explicitly construct an operator which squared coincides with the relativistic formula: derivation of the Dirac equation.
A 4D gradient with some small special relativity specifics added in (the light of speed and sign change for the time).
In the case of field however, we can expand the Lagrangian out further, to also integrate over the space coordinates and their derivatives.
Since we are now working with something that gets integrated over space to obtain the total action, much like density would be integrated over space to obtain a total mass, the name "Lagrangian density" is fitting.
E.g. for a 2-dimensional field :
Of course, if we were to write it like that all the time we would go mad, so we can just write a much more condensed vectorized version using the gradient with :
And in the context of special relativity, people condense that even further by adding to the spacetime Four-vector as well, so you don't even need to write that separate pesky .
The main point of talking about the Lagrangian density instead of a Lagrangian for fields is likely that it treats space and time in a more uniform way, which is a basic requirement of special relativity: we have to be able to mix them up somehow to do Lorentz transformations. Notably, this is a key ingredient in a/the formulation of quantum field theory.
One dimension in position representation: