[1.7.x] Fixed #23483 -- Prevented ImproperlyConfigured with dotted app names

Made sure the app labels stay unique for the AppConfigStubs, so
migrations wouldn't fail if two dotted app names has the same last part
(e.g. django.contrib.auth and vendor.auth)

Backport of 5e32605ce9 from master.