Human intelligence comes from the human brain.
Crow intelligence comes from the crow brain.
Crow intelligence is interesting because it developed separately from human intelligence, and that development resulted in a different brain structure, leading some to assign them "alien intelligence".
In both cases this development was the result of evolutionary selective pressure. In other words, those individuals who had larger more developed brains than others, received benefits from them that outweighed the costs, such as weight and extra energy consumption.
In order for your slime mold to develop intelligence, there would also need to be a similar selective pressure.
The development of a brain might not be required, if you consider the "intelligence" to be a phenomena that emerges from the collective, as we see with ants for example. But ant collectives aren't all that smart, despite each individual ant being far more complex than a single slime mold cell.
But at the very least for your scenario to become possible, there would need to be a selective pressure that made slime mold more successful at reproducing if its colony exhibited more intelligence than other colonies. And this pressure would need to continue to apply all the way from very basic intelligence up to the advanced intelligence you are seeking.
To examine the selective pressures that resulted in the evolution of the brain, and eventually sentience, in vertebrates, you could read up on the evolution of the brain.