It's going to update the one the activity is associated with. So if ID 1 was sent an email, it will update ID 1, but if ID 2 went to the web and filled out a form it would update ID 2.
There is info on the community that discusses how to manage duplicates and merging of records, you will also want to work with your sales CRM team to try to limit the visibility of dupes generated on that side of the equation.