جَاءَ أَحَدَ عَشَرَ طَالِبًا — the numeral is subject, in the nominative position.
رَأَيْتُ أَحَدَ عَشَرَ طَالِبًا — it is the direct object, in the accusative position.
مَرَرْتُ بِأَحَدَ عَشَرَ طَالِبًا — it follows a preposition, in the genitive position.
All three use the same outward form أَحَدَ عَشَرَ. The position changes, not the fixed endings.