EDIT: I’m going to remove the advice here and recommend that OP get an electrician in to check instead.
Not that I think the advice is wrong based on the photos posted - but in case somebody else were to come across this thread and applies it to a different situation.
Where there’s three cables coming out a ceiling, this is normally a loop-in / loop-out circuit plus a switch wire, but there are several different scenarios - and several different outcomes - that could apply here and so to be safe, be sure to get it checked by a competent / qualified electrician
I always label and take a picture of the wires before taking off the old fitting if it’s not a simple 1 cable swap.
I learnt that the hard way after swapping the switches on my landing and both switches had 3 on them for 3 different lights, it took me a week to figure it out.
Ah, I see. I am an electrician, and you’d be surprised just how often you get called to exactly this problem where people would take down light fittings to change them, and then forget what they disconnected
It’s the bulk of callouts by householders.
But to the OP, like I said originally and was repeated by others, any kind of doubt whatsoever - then definitely do get that qualified electrician in to physically look at it - also they will give you a Minor works certificate when it’s been placed back up.
Electricity and Gas are both dangerous, so always take the safe route
It’s just part of the day to day TBH, mostly people will hold their hands up and explain what they were doing and this makes fixing it much easier and quicker.
Occasionally though, you would get people who would absolutely insist they hadn’t touched anything and it 'was always like that" (even though you could see the light was brand new and never used) - and these ones can take longer to try and understand what has happened - particularly if the fitting has gone with a bang.
Anyway, I took down the original advice.
Not because it’s wrong based on what was posted, but I then imagined a situation where someone may find this page via Google and try and apply something different to their particular situation
Wow great responses, I didn’t expect so many. Thank you everyone!
Yes, I foolishly didn’t pay enough attention to how the old light was wired and you’re probably right that I should get an electrician.
I assumed I’d be wasting their time coming out for a job like this and they wouldn’t be interested. @dsd23 has reasured me otherwise with their responses
I’m a sparky by trade too, and this is correct. Loop in (either from CU or light before this one on the circuit), loop out (to next light in circuit), and switch live.