Aged hams like parma hams are cured in a process that exposes most of the ham to enough salt to take out up to a third of the water weight in the haunch. They are kept in an environment that exposes them to little else in the way of contaminants. The “off” parts are cut away before the product is wrapped in an impermeable container for shipping. Christmas hams are brined and then wrapped in a similar container. Even deli hams like cooked ham and chipped ham have a preservative laden fluid pumped into them. All of these products are shipped whole and hermetically sealed away. In your fridge, it usually has its surface area maximized. Its protective container is removed. The environment has drastically changed. Also, except in the case of parma ham, there’s a lot of fluid in the ham for bacteria to enjoy.
The answer for this and most foods are the preserving methods. Bacteria that causes spoilage is killed and controlled through many methods across many foods, such as heat treating, smoking, acid pickling, saltwater brining, air sealing, and others. Salted pork is going to last a lot longer than fresh, because bacteria cannot thrive in salt.
Aging of foods happens in highly controlled environments. Cheeses, meats, spices and whatever else age in rooms that are climate, temperature and humidity controlled, and chemists take samples from each batch and make sure that no harmful bacteria are present. It’s a long and meticulous process and not one you can just do in your living room. Our homes are not as clean as we hope they are, and once ham is cut it’s no longer entirely covered by the protective outer layer.
Latest Answers