The problem, as you ANTICIPATED, is that both gam and mgcv packages install S3 methods for "gam" objects. But, as stated in the ?detach documentation:
registered S3 methods from the namespace will not be removed.
So in your case it is easy to see that is the cause of your problems:
library(gam)
# installs gam::print.summary.gam
identical(getS3method('print', 'summary.gam'), gam:::print.summary.gam)
[1] TRUE
library(mgcv)
# installs mgcv::print.summary.gam
identical(getS3method('print', 'summary.gam'), mgcv:::print.summary.gam)
[1] TRUE
# save a pointer before unloading namespaces
mgcv_psgam <- mgcv:::print.summary.gam
detach('package:mgcv',unload = TRUE, character.only = TRUE)
# after the detach, the method from mgcv is still installed !!!
identical(getS3method('print', 'summary.gam'), mgcv_psgam)
[1] TRUE
Conclusion: make sure you never load mgcv