All the four doors lock automatically at random while driving on 1999 Volkswagen Passat

Once the doors get automatocally locked they can be opened with the lock / unlock switch on the driver side door

Asked by for the 1999 Volkswagen Passat
sounds like you have automatic door locks which lock automatically when the car is in drive and the vehicle is travling at a specific speed which is usually 10MPH. Check your owners manual if you want to deactive this option.