I found the issue. The reason the script can't modify the borders is that once you manually modify the border in Google Docs, the script loses control over it. This seems to be a known limitation with Google Docs tables when modified manually.
You can find more details in this discussion: Google Apps Script Community - Border Modification Issue