I am afraid there is little point in asking why some things are countable/uncountable when logic suggests the reverse should be the case. That's just the way it is. It is often (but not always) true that when the individual units are small (rice, salt) we consider the mass as the uncountable noun, though we can speak of grains of salt if we do wish to talk about the units.
Although the noun 'bean' is countable, it is used in different ways. For certain types, (for example, broad beans) the 'bean' is the seed; for other types (for example, runner beans), it is the whole pod.
Incidentally, we do not usually ask 'How many beans/lentils do you eat?' If we really wanted to know a person's intake of beans, we'd be more likely to ask "How often do you eat beans?' If someone wanted to know the quantity prepared by a chef, they might ask, "How many portions of beans do you prepare/cook a day?" If we asked "How many potatoes/beans do you use a week?" we'd probably get the answer in kilos.
- For Teachers