By doing so, they ensure that the trunk is closed and that no one will jump out of it. But the action goes one step further: it is meant to ensure the officer's own safety. Touching the trunk in a defined area leaves their fingerprints on the car. If they were to be attacked, the vehicle could be linked with the crime.