So yes, this research has been paid for by the German public. However, it is common for universities to apply for patents. Revenue from patent licensing is then usually shared between the university and the researchers.
[1]: http://www.uni-tuebingen.de/fakultaeten/mathematisch-naturwi...
This is the sort of thing that requires and international treaty.
Unfortunately many universities (and hence researchers) are under pressure to commercialise their IP, based on the assumption that such behaviour is beneficial to the economy.
1. Get a patent, find a commercial partner and investors who will give you a ton of money to develop it in the hopes of getting a return.
2. Make it public domain, remove any financial incentive to develop it, then try and convince whoever to give you hundreds of millions of dollars to develop it without any hope of financial return?
The folks I know who work in generics complain about the razor thin margins.