So that got me thinking, how can you tell if something gone past their
date is fermented in a good way, or in a bad way (gone rancid)?
Short of taking the food to a lab and testing it for the kinds of microorganisms in it, the answer is you can't, not really. Lots of dangerous bacteria and other microorganisms don't necessarily make food taste bad.
Or only the process in which you used can somehow tell if the end
product is safe to eat?
Strictly speaking, yes: proper fermentation should follow a known process if you want to ensure safety. The type of food and the conditions need to be correct to avoid dangerous bacteria and toxins in the end-product. Many fermentation recipes use salt to discourage growth of bad stuff. Others use excessive sugar or acidity or something else introduced at some point in the process. Many industrial fermentation processes depend on inoculating the starting material with "good" fermentation microorganisms at the start, so they grow faster than anything "bad" might. Often these "good" microorganisms produce waste products (like acid) that discourage future growth of anything "bad."
It seems like the move back toward fermented foods in the past decade has led to a lot of home experimentation in much less controlled environments. Sure, if you toss quite a bit of salt together with many types of foods and let it sit for a week or two, chances are in many cases you'll end up with something tasty and okay to eat. But true preservation recipes that make use of fermentation depend on exact ratios of ingredients (and sometimes other preparation steps) that have often been lab-tested with dozens or hundreds of samples to ensure safety. If you're not using a known recipe and a known process, it's quite possible to end up with something unsafe to eat.
In the case of the refrigerated cubed pineapple from the question, it's less likely to grow nasty things due to the refrigeration. While it's certainly possible to grow bacteria that will make you sick at refrigerator temperatures, it's more likely that most refrigerated foods will spoil first and taste/look awful and unappetizing before they are able to accumulate significant quantities of other toxins. Still, this is just a general observation, and no one here can guarantee safety for something left in the fridge for a long time. As the mantra goes: when in doubt, throw it out.