جَاءَنِي زَيْدٌ
Translation: Zayd came to me.
زَيْدٌ ← subject; nominative; ḍamma.
رَأَيْتُ زَيْدًا
Translation: I saw Zayd.
زَيْدًا ← direct object; accusative; fatḥa.
مَرَرْتُ بِزَيْدٍ
Translation: I passed by Zayd.
زَيْدٍ ← prepositional noun; genitive; kasra.
Remember
It is still the same person and noun. The syntactic role and the overt case vowel change. The text calls this اخْتِلَافًا لَفْظِيًّا.