As you can see some density and resolution ranges overlap. On those fuzzy edges, the constructor can choose to make its device appear in one range (mdpi) or the other (ldpi).
Even a custom rom could change this setting, so this is really not dependent on the hardware indeed.