Do not immediately label اثْنَيْنِ as genitive just because you see the -ayn form: the same form can be accusative.
رَأَيْتُ اثْنَيْنِ. — accusative direct object.
مَرَرْتُ بِاثْنَيْنِ. — genitive noun.
Rule: Look at the governor and the word’s syntactic function, not only the visible yāʾ.