Finding matching records in a chain to form a parent user
These users form a graph. They are linked by edges to common attributes (email, device etc.). The question boils down to finding disjoint subgraphs within the data, and assigning each a label.
There's an answer on SO which addresses this. The web will have many more if you care to search.
SQL Server 2019 introduced SHORTEST_PATH() which would simplify the query.