Compacting folders frees up space locally, it doesn't do anything to the gmail server.
Unfortunately, Gmail may be special.
Technically deleting attachments creates a duplicate message without the attachments and the original message is then deleted. However, Gmail may keep every message in its archive (see Gmail settings on their website). I am currently unsure about the behavior.