This is exactly it - and once released there is rarely the motivation to go back and optimize side things. The only game I know that has done anything like that is Factorio, or the open source reimplementations of various engines.
The crackers who remove copy protection often repackage (or someone else does) to greatly reduce size; since they’re in there poking around the code they can see what isn’t used.
This isn’t new, either, ancient console games have unused assets and even entire levels in the code but disabled.