The difference between countable and uncountable

Why some words can be used as both caountable and uncaountable while others have to be used as uncountable?? like:

a)fruit, [color=blue]rice, spaghetti, macaroni, sugar, salt, [color=red]corn, wheat, maize

b)vegatable(s), [color=blue]bean(s), pea(s), [color=red]grape(s), out(s), lentil(s)

And by the way what is the difference between the singular and the plural one and if ther’s [size=200]any [color=red]exceptions [/size]just write them down please.

Best regards