I had the same problem and noticed that it occurred when one of my doors or trunk was slightly ajar when I locked the car. But this doesn't explain your problem being intermittent unless the door/trunk you are locking itself is ajar.
For keyless entry, here's a DIY thread from awhile back:
I did it! Keyless entry for your 124 made easy (and less than $100)!
'91 300E, 208k miles