What you're describing kind-of sounds like the proximity lock/unlock feature that GM provided with the early-model (pre-2000, I think) C5's. When the fob is in the "PASSIVE" mode (set via an ON/OFF slider switch on the front of the key fob) the car will [theoretically] lock or unlock the doors, depending on how closely the fob is located to the vehicle, without anyone touching a button on the fob. Why did only the early-model C5's have this feature? Probably because the system was utter rubbish. Recently this system on my '98 coupe started responding erratically to the fob, locking and unlocking the doors despite the fob remaining in immediate proximity of the vehicle. It actually managed to lock the keys (fob and all) inside my '98 coupe -- then wouldn't unlock the doors again. Brilliant... :eyerole
It's conceivable that a low battery in the fob could be responsible for the erratic behavior I experienced, but I didn't try swapping mine out to see if that improved the situation; I just switched the fob's "PASSIVE" setting to "OFF" and plan to leave it there forevermore. If your fob is in the "PASSIVE" setting, I suggest moving the slider switch to the "OFF" position to see if that helps; with "PASSIVE" mode "OFF" the fob functions like every other remote key fob, requiring a deliberate button push to lock/unlock the doors.