كَمْ رَجُلًا لَقِيتَ؟ — How many people did you meet?
Kam occupies the direct-object position: it counts people.
كَمْ يَوْمًا سِرْتَ؟ — For how many days did you travel?
Kam functions as an adverbial of time: it counts days.
The written form kam is identical, but its syntactic role differs. Identify the counted entity and the governing verb.