كَمْ رَجُلًا ضَرَبْتَ؟ — Kam is an accusative object, governed by the verb.
بِكَمْ رَجُلًا مَرَرْتَ؟ — Kam is genitive-position, governed by bi.
غُلَامَ كَمْ رَجُلًا ضَرَبْتَ؟ — Kam is genitive-position as muḍāf ilayh after ghulām.
In all three, rajulan is the accusative interrogative tamyīz. Changing the governor changes kam’s syntactic position, not necessarily its tamyīz.