VW door locks have a small motor inside and microswitches which allow the controller to know if the door is open, closed as well as locked or unlocked. On high mileage cars, the locks can give problems. I have issues sometimes with the back doors on my 2013 Amarok. I have posted an answer here to someone else’s question. Maybe it will help you too. How do I get back passenger door to lock?
The other option is to scan the onboard diagnostics for errors. There should be fault codes logged for all the problems on all of the various controller modules. If you use a decent tool, the codes should be able to tell you if it is the locks or the controller at fault. If you don’t have access to a diagnostic tool, it might be worth asking for a dealership to do a scan for you.