First off, all Governments are to be destroyed when you take a settlement. Don't repair any government (unless you built it, then lost the town, then retook it).

The AI cannot destroy buildings or disband units. They just cannot. There is also no script command to remove a building. So, when a settlement is taken, the script damages (most of the time) the government building 100% so it won't get bonuses and as a signal to tear it down. If the AI takes a settlement, they will get a new government automatically placed (but all previous governments will remain in the settlement, just damaged).

Not being able to repair governments is somewhat of a bug. When more than one of the same building type exsist in one town, the game gets confused. In these cases you can only repair the newest building of that type. Works excellently with the EB government system. To repair a government building that is causing problems, destroy all other governments in that town then add the one (the last one) to the repair queue.

If there are multiple governments in a town and then you either tear down all but one, and add it to the repair queue; or tear them all down and add a subjugation to the build queue... Then you use the "process_cq" cheat, the game will be confused buy the recently destroyed governments and CTD. Another reason not to cheat...