Follow the role of “Zayd’s father”:
جَاءَ أَبُو زَيْدٍ — subject, so nominative أَبُو.
رَأَيْتُ أَبَا زَيْدٍ — object, so accusative أَبَا.
مَرَرْتُ بِأَبِي زَيْدٍ — after بِ, so genitive أَبِي.
The relationship stays “Zayd’s father”; the grammatical role changes the form.