What you have there is the classic ceiling rose with 4 terminals. They may have more than one cable entry, but if you count them there are 4.
L, N, E and switched live.
There's an excellent diagram in the
lighting Wiki which shows how it works and why there are 3 cables there:
It's actually quite straightforward and logical - the circuit cable runs from one light position to the next, so that explains 2 of the cables - 1 in, and 1 out, and a 3rd one goes down to the switch. The problem there is that usually the cable used for the switch is a normal red/black or brown/blue, and often nothing is done to tag the returning black or blue to show that it's
not a neutral, but is in fact a switched live, and a common mistake people make when replacing lights is to assume that all the blacks/blues are neutrals because of their colours, and connect them together.
The other problem is that a light with only 3 terminals cannot directly replace a 4-terminal ceiling rose - you need a 4th terminal for the permanent live.
//www.diynot.com/wiki/electrics:rose
Your roses have got 3-core & earth cables there, and I can't see from the photos exactly what's going on.
But in this:
from L to R you have:
1) A terminal with 3 positions - N in, N out, N for the light.
2) A terminal with 3 positions - L in, L out, L down to the switch.
3) A terminal with 2 positions, switched live back from the switch and to the light.
Re the next photo - have got 2 lights worked by the same switch? Or 2-way switching?