Its complex.

Normally, when you shoot, you have a feed from a boom mic and a lapel on each speaking actor, and sometimes mics picking up ambience and spot FX (like walking, cars etc)

In post production, you can rerecord any dialogue you weren't happy with (ADR) in an isolated space and place it in. You can also rerecord effects (Foley), like footsteps, doors, interactions, even down to fabric moving. Everything is enhanced and unrealistic in films, we come to expect a sort of unnatural sound now.

Then you can add any ambience you like over the top!

That's a quick guide to what normally happens (I think its right, but i'm not 100%. Can anyone confirm?), hope it helps!
most ambient sounds are added after the initial recording. even something as simple as someone brushing dirt off of a sleeve or something. depending on how you are recording the audio and video real time, a lot of that stuff may get picked up during your takes. anything you want to enhance or add gets put in later. with some more high quality a/v gear, they can isolate what they want from the live takes, and can add in everything later (which is what most high quality productions would aim for).