How can I customize the link when an attached image is clicked?

You say you click the Save All Changes button. I think this means you are trying to edit the images via the Upload/Insert images button above the editor? It’s confusing, but this is not the place to edit an individual image that you already inserted into the post. In the Gallery tab you can edit settings for the image in the shared Media browser, but not for already inserted images. You need to do that by clicking on the image and then clicking the first button that appears (showing an image). This will give you a slightly different editing window, with an Update button at the bottom.

If the rel attribute of the image link is set to attachment, _fix_attachment_links() will replace the link with permalinks to the attachment when you save the post. So make sure that when you edit the image link, you first click the “None” button to clear this value, or go to the Advanced Settings tab and edit Link Rel so it doesn’t contain attachment.