Because if power comes first to the light, you need a "switch loop" to the switch. The two necessary wires in a "switch loop" are:
- Always-hot (so the switch has a source of power to convey onward) preferred color black.
- Switched-hot (hot when the switch is on, obviously) preferred color red.
On hot wires, any particular color is not required, it simply needs to be not white gray or green. These are mild preferences.
Now if you look at the North American market for cables, you'll find a whole lot of 2-wire+gnd cables that have black and white wires. You will not find any cables that are black and red. So wiring a switch loop presents a cable supply problem.
Rules for re-tasking the white wire
The cure to that problem, post-2011, is to require neutral to be brought on switch loops separately and also, which means you use /3 cable which is black-white-red. Solved.
However, prior to 2011, you would re-designate the white wire to be a hot. We have specific rules for that.
- White must be neutral if neutral is in the cable. Otherwise
- White must be always-hot if that is in the cable (but neutral isn't). Otherwise
- White can never be switched-hot to the lamp. (which leaves "traveler").
So, on a pre-2011 /2 switch loop, white will always be always-hot, and black will be switched-hot. It has to be that way; the reverse would violate two rules.
Because if the were exchanged, both wires to the lamp would be white. How on earth would you tell which is neutral? That would be bad, since electricians notoriously refuse to mark the wires with phase tape.
Now, neutrals must be marked
Also, neutral wires re-assigned to a "hot" must be marked with electrical tape or paint. Yours are not properly marked, but on the other hand that requirement came into Code in the first decade of the 21st century. Feel free to install the marking.
The marking also does the very useful thing of telling you which of these two cables is a switch loop.