You can count a loaf of bread or a slice of bread, but "bread" by itself is not countable.
Same with candy, at least in the U.S. -- you can have a piece of candy, or you can just have candy. I think native English speakers in other countries might give you a different answer about candy, though.
Now as far as the reason, I am not sure. Leaves are always countable, and so are biscuits. You can use "cake" either way, though. "I'd like a cake" means you want the whole thing, or you can just ask for one or two slices of cake. Or you could just ask for "some cake."
For mass nouns, you can count them if you specify the amount, such as "2 gallons of" gasoline, or "a jar of" dirt. That also works for bread. I hope that's a little helpful; I know it's confusing. Good luck with your studies!