As said upper the attribute definition is a template sort of. At this programming level, there's none automatic link between an attribute defininition and an attribute reference.
You can create a block reference which do not have any attribute reference despite the block definition contains attribute definitions. And, as you noticed, you can also create a block reference which have attribute references different from the attribute definitions contained in the block definition.
At upper level, the ATTSYNC command re-creates the attribute references according to the attribute definitions, as done with the code I posted (in the (foreach att (reverse attDefs) ...) loop, the 'elst' variable is a list containing the DXF data of the attribute definitions used to 'entmake' the attribute reference).