As explained in this support document -> Two-factor authentication for Apple ID - Apple Support all your trusted devices are devices you’ve confirmed are yours and under your control, hence they all simultaneously get the code whenever a 2FA code is required to login with your AppleID. Trusted devices receive their codes over the internet via encrypted iCloud notifications.
”Trusted devices
A trusted device is an iPhone, iPad, or iPod touch with iOS 9 or later, or Mac with OS X El Capitan or later that you've already signed in to using two-factor authentication. It’s a device we know is yours and that can be used to verify your identity by displaying a verification code from Apple when you sign in on a different device or browser. An Apple Watch with watchOS 6 or later can receive verification codes when you sign in with your Apple ID, but cannot act as a trusted device for password resets.”
It is up to you to secure your own trusted devices.
“What to remember when you use two-factor authentication
Two-factor authentication significantly improves the security of your Apple ID. After you turn it on, signing into your account will require both your password and access to your trusted devices or trusted phone number. To keep your account as secure as possible and help ensure you never lose access, there are a few simple guidelines you should follow:
- Remember your Apple ID password.
- Use a device passcode on all your devices.
- Keep your trusted phone number(s) up to date.
- Keep your trusted devices physically secure.”