In English there is quite a difference between:
1. I knew 21 of the men.
2. I knew the 21 men.
The Czech sentence here means 2, not 1, I believe.
Twenty-one of those men would use z těch mužů I think. That would be a partitive use of the genitive. Larger numbers use a genitive of content where the number is referred to as a collection and the counted thing is in the genitive describing the contents, as in "a flock of birds". One could write a construction like this in archaic English "The score and one of those men did I know."
So, even though "men" is a direct object (accusative case), 'ten' becomes 'těch' because of the genitive plural rule for 21?
Muž isn't the direct object. The direct object is the collection of twenty one, and it's a collection made up of those men. The word order makes it even trickier to understand. Ten becomes těch to agree with mužů, and it is at the start of the phrase because it's a demonstrative. Compare with the English "those dozen eggs".
The second place rule applies here too, however, it does not always have to be the second word. In this sentence, the subject is in the first place (mužů), but it's developed so all the words that develop it will stick to the subject and are considered to be in the first place too. I don't know if this is the correct word in English, but clitics are the second element in a sentence.