Let's do a dry run on strs = ["eat", "tea", "tan"] step by step.
For "eat": sort it → "aet". Map: {"aet": ["eat"]}.
For "tea": sort it → "aet". Key exists. Map: {"aet": ["eat", "tea"]}.
For "tan": sort it → "ant". New key. Map: {"aet": ["eat", "tea"], "ant": ["tan"]}.
Return the values: [["eat", "tea"], ["tan"]].
Sorting each string takes where is string length. You do this for strings. That's time.
The hash map stores all strings, so space.