They count the spending in different places in these two cases, but it's the same idea.
You spend X on something that gets stolen. X counts towards GDP.
The government steals Y from you and spends it themselves. Y counts towards GDP.
It's conceptually the same mistake. X and Y weren't acquired voluntarily by their ultimate consumer, so we can't say that the consumption was worth X or Y.