It totally depends on your knowledge and training.
Are you competent to help in some way?
Are you good at first aid, if you are, are you afraid of being sued?
Do you know how to effectively direct traffic around the scene and are you equipped to do it?
If you don’t have something unique that can help rather than hinder you should either leave, assuming you didn’t see the accident and can’t be a witness. Or, if you did see the accident, give your contact information and then leave. If you didn’t see the entire accident from start to finish you are not an effective witness. You have to have seen everything leading up to and including the crash to be of much use.
If you are going to stay try to position your car either completely off of the road or in such a way that it shields the scene. If you don’t really know what you are doing get it off the road! You will at best hinder traffic including emergency vehicles and at worst get it involved in secondary accidents.
Unless you have experience never try to cross a busy highway unless all traffic is stopped and there is no path that a car could come from, such as a shoulder.
If you see an accident occurring ahead of you turn on your ER blinkers and slow while swerving back and forth in your lane.
STAY IN YOUR LANE! DON’T SLAM ON YOUR BRAKES OR STOP!
Once traffic has stopped if you have a road flare carry it back a good distance to alert any approaching cars but stay far from traffic lanes.