It can be used to determine what an object is made from because every object in the world has a different mass per 1 specific volume of that object
Different objects have a different number of atoms in 1 cm/ml cubed of the object, therefore, it will result in a different mass hence a different density. Another object, no matter how similar, will never possess the same density; as the mass per cm/ml cubed will change depending on the object/substance.
That's the reason why a 20 cm cubed gold bar will have a different mass than a 20 cm cubed silver bar. Even though everything is the same they possess different masses based on 1 cm cubed of the substance
In short, density is like a fingerprint. Nothing else can possess it although some could be similar.