Localized electronic states induced by defects and possible origin of ferroelectricity in strontium titanate thin films