The implementation details for this will vary wildly among themes so just following some tut will not always apply.
Undocumented - In some few themes with simple javascript the variant id input field in a product form can just be made to submit the same quantity of multiple items by appending brackets, , to the name attribute value, name=“id”, to indicate multiple ids. So then the addon products id can be added with an additional input. However most themes use javascript functions to submit the cart in ways that ultimately ignore the actual underlying html&form behavior.
Ie.
becomes
Note with this workaround all quantities will be the same.
Otherwise for javascript ajax methods start with the fundamentals:
https://shopify.dev/api/ajax/reference/cart
For cart based product adding also reference the gift-wrap customization:
https://help.shopify.com/en/manual/online-store/themes/themes-by-shopify/vintage-themes/customizing-vintage-themes/add-gift-wrap-option With a little javascript know how that can be automatically added instead of using the checkbox display.
And this old github repo for vintage themes https://github.com/carolineschnapp/add-product-to-cart-automatically
Good hunting.