Notification badges doesn't work well with multiple iOS devices
How the notification badge count for an iOS app is updated across the app life cycle events depends on how well the app developer has implemented it.

In an ideal scenario, if the app developer has carefully planned for and implemented it correctly, the badge icon should sync and update when the network activity happens on the other devices and the appropriate handler method for background app refresh gets a chance to run its code.

In some cases, it may so happen, that the implementation isn't done completely/correctly by the app developer. In such cases, you may continue to see an out-of-sync badge count on the other devices, as the app hasn't got a chance to execute necessary code yet.

When the app actually get the chance to run in the foreground, it generally communicates with the back-end servers and re-sets the badge count, the count comes to sync (as you are observing).

In the cases where the implementation is done all-right by the app developer (the competent ones usually ensure this), the rare chances when the count doesn't sync may be observed, either when the device hasn't yet got a chance to get an active connection to the Internet, or is either running in Low Power Mode (only applicable to iPhone), where the Background App Refresh is disabled by the iOS to preserve battery life.

Additionally, to optimize battery life, the iOS subsystem shuts down the device Wi-Fi connection after a set interval post device has gone into sleep mode.

Thus, with an active Internet connection, on the devices with Low Power Mode disabled, you should see the badge count sync within seconds on most of the apps.