رَأَيْتُ أَحْمَدَ — Aḥmad is an accusative direct object; fatḥah marks accusative.
مَرَرْتُ بِأَحْمَدَ — Aḥmad is genitive after bi-; fatḥah marks the genitive of a diptote.
The visible ending is the same, but the grammatical case is different. Identify the governing element first.