Mary bought bread and meat and cheese and some butter.
Do I have to put any commas in this sentence? If the answer is yes, then how many commas and where should they stand?
Punctuation is a matter of style. The usage of multiple ands is unconventional, and I don't know of any style guides have any recommendations for this.
Normally, you would replace all except the final and with commas:
Mary bought bread, meat, cheese and some butter.
There is an alternative scheme where you also place an Oxford Comma before the final and:
Mary bought bread, meat, cheese, and some butter.
As it was said, in a list which contains three items or more, in most cases it is better to replace all ands except the last one with commas. Such pattern, with a single conjunction, is used in majority of contexts.
But there are a few situations where repeated ands may be a better choice. In English, commas are not restricted to separate items in lists; sometimes they are used to set off appositions. Thus, in such cases repeated conjunctions may be used to resolve ambiguity. For example, let's take the sentence:
They went to Oregon with Betty, a maid(,) and a cook.
Suppose that there were three persons: 1) Betty; 2) maid; 3) cook. If we write the sentence above as They went to Oregon with Betty, a maid and a cook., without the Oxford comma, then there's a possibility that the entire construction 'a maid and a cook' is an apposition to 'Betty', which means that there was only one person. If we try to use the Oxford comma, or a serial comma, then the sentence will look as follows: They went to Oregon with Betty, a maid, and a cook. Now, it would be still possible to understand the word 'maid' as an apposition to the noun ‘Betty’, so the sentence could mean that there were only two persons: 1) Betty (who was also a maid); 2) a cook.
However, if we rewrite our phrase using two ands, then we should obtain: They went to Oregon with Betty and a maid and a cook. Here, it is completely clear that they were accompanied by three distinct persons. (https://en.wikipedia.org/wiki/Serial_comma)
Usually, construction "x and y and z..." does not require any commas inside of it:
I have English and math and science homework. (https://www.englishgrammar101.com/module-7/conjunctions-and-interjections/lesson-1/coordinate-conjunctions)
There are some writers who prefer this style, although it is not widespread. Still, it can be totally possible to use more than one and without using commas in the same phrase in prose or in poetry.