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:
http://www.peachparts.com/shopforum/showthread.php?threadid=11777
Good luck..
~Paul
_____________________
'91 300E, 208k miles