By default, every new device is treated as a new contact, however we can merge contacts based on similar information such as their email address/phone number etc.
This is actually done via Automation flows.
Create a new flow.
If you want, add a trigger, e.g. form submission.
Click and drag the “Lookup Contact” flow step onto the canvas.
Select which field(s) you want to search for duplicates.
Choose the “Action to take when contact matched”.

It’s good practice to have every single automation start with this flow step.
Email or Phone number are usually the best fields to use for contact matching, but you may want to merge if email or phone and first name and last name match, which you can do with the AND/OR options in the filter.