where does $checkout in form-checkout.php woocommerce come from? [closed]

It’s set by the code that includes the template, and is in-scope when the file is included – from the include documentation:

When a file is included, the code it contains inherits the variable scope of the line on which the include occurs. Any variables available at that line in the calling file will be available within the called file, from that point forward.

form-checkout isn’t used in isolation, it’s included from another class with wc_get_template:

wc_get_template( 'checkout/form-checkout.php', array( 'checkout' => $checkout ) );

and that argument becomes $checkout: wc_get_template calls extract on that array before it does the actual include to generate $checkout in-scope.