That you can do this comes from the fact that TLorentzVector defines a constructor taking 4 doubles where you can omit as many arguments as you like. The missing arguments are taken as 0 then.
TLorentzVector(Double_t x = 0.0, Double_t y = 0.0, Double_t z = 0.0, Double_t t = 0.0);
In your case you gave x and everything else was set to 0.
I think this constructor is totally silly since it makes little sense to only give one component. Either give all components or none (which would set everything to zero). I.e. replace above function with