To add to what @JDRoberts said, each hub has its own set of apps installed and currently one app can only connect to one hub so if the two locks are on different hubs one SmartApp cannot directly control locks on two separate hubs (you can use a special API app below).
If you’re using an app like Lock User Management (LUM), you will need to manually synchronize the codes entered into the app to keep the two hubs in sync. However if BOTH locks are connected to the same hub (e.g. two offices on the same floor connected to a single hub), then you can add both locks to the same app and it’ll synchronize the codes across both the locks. Once ST supports multiple hubs per location and apps, the LUM app will be updated to support that feature.
For now if you have two separate hubs, the way to synchronize the codes across multiple locations is to have a REST API integration using Lock Manager API. Most commercial organizations are using this app to synchronize users remotely for their rental properties and offices located geographically in different locations/hubs.