(Note this contain spoilers)
To determine whether a spirit is light or dark, light spirits have a light-coloured circle around their space on the map, and dark spirits have a dark-coloured circle. In the Final Battle, the light spirits are on the left and the dark spirits on the right, but the coloured circle helps for determining cases in the middle on the world map. The full list of light/dark spirits is shown below:
Back to the question, there are two bad endings. One is where Darkhon wins (obtained after beating Galeem alone), and another where Galeem wins (obtained after beating Darkhon alone). In the Final Battle, there are multiple ways to get one of the bad endings:
Beat a relatively high number of light spirits compared to dark spirits. This will open a path to Galeem letting you fight and beat it alone. When you beat enough spirits, a path to Galeem will open and an in-game message will appear to confirm this. Beating more dark spirits instead lets you fight Darkhon alone. If you've beaten all the light spirits and the path still hasn't appeared, it's probably because you've beaten too many dark spirits as well, in which case this option is no longer possible.
After freeing both Master Hand and Crazy Hand, and then defeating 50 puppet fighters with Master Hand (the Master Hand Mob Battle, only available when the ratio of light to dark spirits defeated is approximately equal), three paths open up. One to Galeem alone, one to Darkhon alone, and one to both together. Once this is done, the 3 paths will always remain irrespective of the spirits you've beaten.