When merging 2 Constituents and only one has a membership:
Ensure that the Constituent with the membership is selected as the Target

When merging Constituents that both have memberships:
  1. Delete the membership from one of Source Constituent
  2. Ensure that the Constituent with the membership is selected as the Target when merging
  3. Readd the deleted membership to the Target Constituent after merging
For more information on assigning contribution based membership refer to the help documentation.