Locking system on a 1988 BMW 325i convertible

My car locks it self up after I shut it off and pulling the key and I get out of the car, some times a minute or two after and sometimes an hour or longer, and sometimes when I’m getting out while the door is open it locks and unlocks itself 2 or 3 times before I close the door.

Have your mechanic check the door lock/unlock relay. Door locks operate with or without the key in the ignition. Have the mechanic check the door lock/unlock switch also. If they break internally they can cause it to operate with temperature changes or jarring of the vehicle.