To try and put it simply:
After the numbers 2, 3, and 4, nouns are in the genitive singular. Adjectives between the number and the noun, however, go into the genitive plural.
три больших книги
After numbers greater than 5 (excluding numbers which end with the digits 1-4), both adjective and nouns go into the genitive plural.
пять больших книг
Тhis rule applies when the number is in the nominative or accusative (inanimate) case.
In other cases, the number and noun both appear in the required case, and the noun is always in the plural.
Это город трёх моих друзей. (Genitive)
Я написал письма двум моим друзьям. (Dative)
Я говорил с двумя моими друзями. (Instrumental)
With regards to 2-4, the pattern of # + adj (gen. pl) + noun (gen. sing) changes in the accusative animate.
Inanimate: две новых машины
Аnimate: двух новых друзей
With accusative animate, both adjectives and nouns go into the genitive plural.
-----------------------------
With that explanation, I'll answer your question directly.
We know now that the number 4 will be followed by a noun in the genitive singular case, and 6 will be followed by a noun in the genitive plural case.
In order to know how to decline the noun into genitive, you have to know the nominative singular form of the noun.
Чашки and чашек are the genitive forms of the word чашка (cup), a feminine noun.
Feminine nouns in the genitive singular are found by dropping the а or я (IF the noun ends in а оr я, but that's a whole different lesson) and replacing it with ы or и. So чашка becomes чашк and then we have to add the ы, except you can never write ы after a letter к, or any other gutturals (Г, К, Х) or sibilants (Ж, Ч, Ш, Щ, Ц) for that matter (called the 7-letter spelling rule). This yields a genitive singular of чашки.
The genitive plural for feminine nouns is reached by dropping the а or я (this applies to some neuter nouns) and leaving it. However, if this leaves the word ending in a consonant cluster, often times a "fleeting vowel" will appear to break apart the consonants. So the genitive plural чашка would be чашка - а = чашк, but since there's a consonant cluster (шк), which isn't very natural to say, at the end, a fleeting vowel (the e) appears, and you get чашк -> чашек.
Аnother example similar to this word is девушка (girl). Genitive singular would be девушка - а + и = девушки, and the genitive plural would be девушка - а, but since девушк ends in a consonant cluster, you get девушек.