It is. It's called Compulsory Licensing.
There is also an FDA Shortage list (most countries have a similar list).
A drug on that list gives the government additional powers to allow companies to work around the parents.
I think this is why there has been so many "off-brand" weight loss drugs recently. Novo Nordisk had supply chain issues with semaglutide, triggering governments to allow other manufacturers