This issue can be caused due to a missing value in the CategoryPath for the apps in [dbo].[com_K2_App_Framework_Core_SmartObject_RegisteredApp] table.
Before You Begin
If you have not deleted the 4.7 apps after the upgrade to K2 Five 5.1, updating the CategoryPath with the correct value will allow the app to be removed from the Workspace > Published Apps page correctly.
Once you have deleted the 4.7 App from the Workspace > Published Apps page, and by removing the entry associated to the app that you deleted from the [dbo].[com_K2_App_Framework_Core_SmartObject_RegisteredApp] table, will allow the 5.1 app to be installed and updated successfully.
Please make sure to stop the K2 Service, and back up the K2 DB, prior to removing the entry from the K2 DB.