Generally speaking, data elements in DTM are configured to retain the value for the first matching item detected on the page. It is possible to configure a data element to return multiple values, but it is necessary to use an object or array under custom.
Alternatively, dynamic logic can be used within the specific rule itself. There is related content under 'Populate Dynamic Variables' in the documentation here: https://marketing.adobe.com/resources/help/en_US/dtm/global_variables.html
For example:
There are multiple links on a page. In this case, the intent is to capture the value of the 'data' attribute into an eVar for the specific link clicked:
<a id='myFirstLink' href='www.exampleLink.com' data='data1'>
<a id='mySecondLink' href='www.exampleLink2.com' data='data2'>
<a id='myThirdLink' href='www.exampleLink3.com' data='data3'>
In the rule, configure the rule condition to fire on the click of 'a'.
Then, the value of 'data' for the link clicked is set up to pass into an eVar. It is set up dynamically as follows:
eVar1="%this.getAttribute(data)%"