Those two words have the same pronunciation, they cannot be distinguished when spoken. But when writing, how do we know if we need to add an accent to the -a?
They have two different functions. -a, without the accent, is a form of the « avoir » verb.
Le chat a sauté sur le canapé. (The cat jumped on the sofa)
Léa a lu toute la nuit. (Léa read all night)
-à, with an accent, is a preposition.
Nous sommes à la maison. (We are home)
Tu vas à Paris. (You go to Paris)
There is a tip!
Replace the word by « avait », (avoir at the imparfait). If the sentence still means something, then the word is the verb « avoir », and there is no need for an accent.
Le chat a faim. (The cat is hungry).
Le chat avait faim. (The cat was hungry). This sentence still makes sense. The verb is « avoir », so there is no accent on the -a.
Les enfants sont à la bibliothèque. (The children are at the library).
Les enfants sont avait à la bibliothèque. (The children are was at the library). This sentence makes no sense. The -a is not the verb « avoir », it is a preposition, an accent is needed : à.