Other than the second try on locking working perfectly, that sounds like a problem with the actuator. But it could be that the unlock and second try on locking somehow aligns the locking part of the mechanism better so it locks easily.
I rebuilt my driver's door lock actuator successfully a couple of years ago. Plenty of pics and description in here for you, in case anything helps:
https://xoutpost.com/bmw-sav-forums/...or-repair.html
One big difference I notice though, between my issue and yours, is that on mine, locking was perfect and unlocking was weak. Yours sounds opposite.
The root cause of the problem was one of the two little motors in there failing. That's why it could lock perfectly and would unlock weakly. Most door actuators like this seem to do it all with a single motor, but these have two.
As shown in that thread / post, replacing the actuator is easy. The hard part is taking the actuator apart and putting it back together - it was definitely not designed for that. But I found mine to be amazingly well built, other than the single motor that failed - and it basically just wore out - carbon brushes disintegrated.