That's not exactly how it works.
When embedding a Tweet button using the Twitter JavaScript API, you also need to include a script reference to //platform.twitter.com/widgets.js. This code scans the DOM, reads those data attributes and then replaces the href above with an iframe. That iframe contains the Tweet button with the data attribute values serialized into a new href that triggers the popup.