It's hard to help you because there isn't a clear reproduction scenario for your local dev environment.
I expect that somewhere in your logic a new object is being created which may cause your association to fall away but again, that's hard to say.
You can try to use the debugger linked to the production environment to find out if you are losing the association somewhere.
This may be a little unusual but good to know:
You can commit your non persistent objects: committing non-persistable entities records the current attribute values and association values in memory. I'm not saying this is THE solution, but it's good to know now. https://docs.mendix.com/refguide/persistability#non-persistable