Basically 3 points to keep in mind.
-
Were you involved?
-
Do you have useful and relevant information (e.g. a dash cam that captured what happened)?
-
Can you provide additional aid?
The first one is obvious, if you're involved, you stop and at least provide contact details.
The 2nd is harder, but not too hard. If it happened right in front of you, pull over somewhere safe, if possible. If you can't, contact the non-emergency police line afterwards. They will be able to advise.
The last is the complex one. If you're the first on the scene, any aid is better than one. If you're not, then judge whether you can provide more help. E.g. 1 person trying to help multiple victims, or an elderly individual, who might not be physically capable of rendering aid.
A side note is providing protection. I drove a larger vehicle. I recently witnessed a motorway accident (driver fell asleep at the wheel). A depressing number of drivers were dangerous idiots. Several cars drove between stopped vehicles to get past. Some got very close to running over rescuers. I ended up using my van to block off the immediate area, and force traffic well clear.
Basically, keep yourself safe first, keep others safe second, render aid third. If you can't do any of those, either wait patiently, or maintain the traffic flow as best you can.