Sometimes the cut in the roof is not adequately framed. Are the edges of the roof opening flat and supported by metal or wood framing? The top and bottom of the opening should be filled with a metal or wood square that prevents collapse of the roof or ceiling when bolting it tight. Only the gasket should compress, not the roof or ceiling. I think you'll need to remove the A/C, build a proper frame into the opening, then reinstall. You need to give it proper support to prevent future leaks, rot, or rusting. Don't be tempted to fill the gap with more foam or caulk, do it correctly or have it done.
Bob & Donna
'98 Gulf Stream Sun Voyager DP being pushed by a '00 Beetle TDI