The screen writer(s) write the script (s) with the planned sequence of events, including all dialog and action, possibly based on original fiction, or story outlines, etc., and with lots of input from the director and producer(s), etc.
The director shoots the scenes in the final draft of the script in the order which the director and producers have decided on (which is a complicated decision-making process) for making the movie fastest, cheapest, etc. Some times final draft script pages are delivered to the movie set on the days those scenes are to be filmed.
Sometimes the director on the set decides not to film entire scenes in the script or to add more scenes and often to change dialog, etc. Actors sometimes ad-lib their lines, and sometimes goofs in filming a scene are left in the movie because they make it funnier.
After production and adding special effects, etc. to footage, the editor (under the director's supervision) edits various shots from various takes of a scene into a complete scene, and does this for all the scenes, and assembles the scenes into the complete movie.
Sometimes entire scenes, characters, and plot elements are "left on the cutting room floor" during editing and are not in the final movie.