The first diagram used to be valid, but hasn't been any good for a decade now
Back in the olden days, the first diagram used to be a perfectly cromulent way to wire a set of lights to a single switch with power coming in at a light and a downline always-hot provided for receptacles. However, the 2011 NEC added a requirement for neutral to be provided at all switch locations, so that lighting control gizmos could power themselves without causing annoying malfunctions, such as flickering or dimly glowing LED loads, or naughtily trickling operating currents onto the equipment grounding system for that matter.
As a result, assuming that we're dealing with a 15A circuit, the 14/2 going down to the switch in that diagram needs to be replaced with a 14/3, with the black wire carrying always-hot down from the incoming feed to the switch, the red wire carrying switched-hot back up from the switch to the lights, and the white wire tied to the incoming feed's neutral, but left capped off at the switch location for future use.
The second diagram, though, never was Code compliant
While the second diagram isn't impacted by the 2011 NEC changes to require neutrals at switch locations since there is a neutral available at the left-hand switch as a function of power coming in there, it wasn't ever Code compliant to begin with, even though it works. Why? Well, in order to figure that out, we need to understand a thing or two.
Most people think of electricity in terms of DC, where magnetic fields are a non-factor and wires can be run any way you wish (such as in a car) without causing interference with other wires. However, that no longer holds when we start talking about mains electricity since it's AC, not DC. In particular, any loop of wiring with AC flowing through it has a varying magnetic field inside that loop. This magnetic field can be quite useful, as it's what allows us to have handy-dandy electromagnetic gadgets like motors that work readily, and also allows us to build transformers to step AC up and down.
However, it comes with downsides as well; in particular, if you put a wire carrying AC power out to a load some distance from its corresponding neutral that returns power from that load back to the utility, you now have a time-varying magnetic field inside your wall. Since putting an iron object in a magnetic field induces current into that iron object, and iron isn't a great conductor of electricity, any iron object that is in that time-varying magnetic field heats up. This is wonderful when it's happening to a pan on your induction cooker, and very bad if it's happening to say, a nail inside your wall.
As a result of this, NEC 300.3(B) and 310.10(H) effectively prohibit splitting a wiring path between cables, as was done in the second diagram with the two 14/2 cables between the light fixtures. Instead, you need to combine those two runs using a single 14/4 cable or 5 14AWG wires in a 1/2" ENT ("smurf tube"). This way, all the magnetic fields are contained within the cable sheath or conduit, so they won't leak out to the point of heating up nails in your walls.