Variety of sources likely
Stagnant sea water has organic stuff decaying, and they give off lots of smells (most noticeably the "rotton egg" variety from hydrogen sulphide). Molds & mildew can give off a persistant odor (which can adversely affect health). Certainly, petroleum products (oil, fuel, etc), coolants, and many cleaning agents have distinctive odors. And, the marine head with its hoses, etc. can emit odors. Cooking greases, dead rodents, ... the list goes on. Someone with an acute sense of smell can probably identify many of the sources.When boat shopping, look for evidence of good vs sloppy "boat keeping" -- a sloppy boat will likely have greater odor problems to resolve. Be sensitive to the one-time cosmetic overlay to "sell" a boat. When boat-shopping, look for the items listed below, for starters.Once you purchase, the first order of business would be to really thoroughly clean the bilge, inner hull and bulkheads. The inner hull & bulkheads (especially behind stuff) get condensation and molds & mildew can form there; in severe cases, you might have to dismantle a lot of stuff just to get to it. Thoroughly clean the engine of accumulated grime (dirt + petroleum); ensure the engine exhaust and oil sump venting isn't leaking into the cabin spaces. Make sure there are no fuel leaks, too. Keeping a clean engine & engine compartment will quickly reveal any leakage problems.Make sure the sanitation system (toilet, hoses, holding tank, etc) is sealed and properly vented; do the "rub test" on all hoses. Old cushions & pillows (and PFDs) may be a source of many smells and have to be replaced.Make sure the boat regularly gets thoroughly aired out & is vented when shut. Use mildew-deterent bags throughout when closing the boat up for a season.Will all that ever get totally rid of the smell -- don't know, but it will abate much of it.Good luck--RonD