How does WordPress differentiate what scripts are loaded in wp_head() and wp_footer()?

wp_enqueue_scripts has a parameter which specifies if the script should be rendered in wp_head or wp_footer

The function signature is this:

wp_enqueue_script( string $handle, string $src="", array $deps = array(), string|bool|null $ver = false, bool $in_footer = false )

Note that it is the 5th parameter, so if you wish to not have any dependencies and use the default version number for your script you still have to supply those parameters. For example:

wp_enqueue_script( 'your_script_name', 'your_script_location', array(),false, true );
                                                                                ^     
                        //  This will cause the script to render in wp_footer   |