I think you are aware, that you can create hooks on install process.
E.g. https://docs.joomla.org/J2.5:Managing_Component_Updates_(Script.php) https://docs.joomla.org/J3.x:Creating_a_simple_module/Adding_an_install-uninstall-update_script_file
Here is my approach, where I after install publish plugin as an example https://github.com/gruz/NotificationAry/blob/master/scriptfile.php
You can use postflight hook in your demo data extension to uninstall itself programmatically.
I did such a thing in the past but I don't have an example.
Or you can, if you have a plugin you develop which assumed to be installed before the demo data extension install, in that plugin check what is installed and the uninstall that extension. There is a bunch of hooks for it. https://docs.joomla.org/Plugin/Events#Extensions
And, as an option, you can add an upload button to your component to upload test data and handle it in your component - get uploaded file, extract if needed, run queries from the file. Then no need with install-uninstall programmatically. I'd use such an apporach.
But self-uninstall seems interesting to be implemented just for fun :-)
P.S.
A point to start looking how to self-uninstall. https://stackoverflow.com/questions/44155005/joomla-3-xx-how-to-uninstall-and-install-component-or-package-programmatically#44203211
Or, dirty way, run query to remove corresponding record from #__extensions and unlink files. But I'd rather examine Joomla API and find a legal way to programmatically uninstall an extension.
P.S.S. https://docs.joomla.org/Extension_Installer/Installer_Hooks
The preflight hook ... At this point you could conceivably prevent the installation by calling the abort mechanism from the parent or prepare anything ahead of the file copy and database changes occurring. ...
As an option In preflight hook execute you demo data install code but return false to pervent your extension instllation. Add a message for a user "Demo data installed, ignore joomla error message on failed installation
". :-)