A:Answer For the PS3, pair it by connecting it via usb cable.
(https://www.nacongaming.com/en-US/blog/ps5-controller-ps3)
For PS4, you will need to purchase a bluetooth adapter. I prefer 8 bit do for connecting the PS5 dualsense to my switch. I would think that it should also work with connecting a PS5 dualsense to a PS4.
You can also use Remote Play for PS4, but I world imagine that would be a lot of lag.