Some nouns can be both countable and uncountable, depending on context. Most of your list fall into that category.
Soup is usually uncountable. You can sometimes use it as countable if you were referring to a recipe, or a dish, and usually in abstract terms. 'Would you like a soup to start?'. 'I sometimes make a vegetable soup in the winter'.
If it is a block of cheese, it is a cheese. If it is a smaller quantity of cheese, it is cheese.
Butter is uncountable. We would usually say 'a pound of butter' or 'a pack of butter'.
Lettuce is countable if it is an entire head of lettuce. It is uncountable otherwise (e.g. there is some lettuce in this salad)
The same is true with cake and onion. If you have a whole one, it is 'a'. If it is cut into pieces, it becomes some.
A beer is a bottle or a glass of beer. i.e. a serving of beer. The actual liquid is uncountable. If you pour some beer into a glass, you have poured a beer.