If it's physical size is close on all devices, then why was it needed when we have an absolute unit like mm?
It is. If you were to draw a 100dp line on any device and measure it with a ruler, it would be the same length. What differs is how many pixels are in that line- that changes based on the ppi (pixels per inch) of the screen, which can vary greatly between devices. We use dp rather than px to get around that difference.
As for why its needed when we have mm- because someone decided this would be a more convenient measure than mm. Remember that the US is not a metric country and is both where Google is located and the majority of tech companies. mm isn't friendly to them. Inches is more familiar there.