anfallen
to attack
To suddenly and aggressively physically attack someone or an animal.
Der Hund ist ohne Vorwarnung den Postboten angefallen.
The dog attacked the mail carrier without warning.

to attack / arise / come over
Loading your saved state.
to attack
To suddenly and aggressively physically attack someone or an animal.
Der Hund ist ohne Vorwarnung den Postboten angefallen.
The dog attacked the mail carrier without warning.

'Anfallen' is a separable verb. The prefix 'an-' goes at the end in a main clause. In subordinate clauses or in the infinitive with 'zu', the verb stays together.
Der Hund fällt den Briefträger an.
The dog attacks the mail carrier.
You can recognize the meaning from the subject: if a living being attacks, it refers to an attack. If the subject is something abstract like 'Kosten' (costs) or 'Arbeit' (work), it means 'to arise'. If the subject is a feeling, it means 'to come over'.
Der Löwe fällt seine Beute an.
The lion attacks its prey.
In the meaning 'entstehen' (to arise), 'anfallen' is almost always used for impersonal things. Typical examples are costs, fees, work, trash, or data.
Bitte entsorgen Sie den Müll, der bei der Feier angefallen ist.
Please dispose of the trash that was generated during the party.
When a feeling comes over someone, the feeling is the subject and the person is the accusative object. So the sentence structure is: [feeling] fällt [person] an.
Mitten im Gespräch fiel sie eine plötzliche Angst an.
In the middle of the conversation, a sudden fear came over her.
to arise
'entstehen' and 'anfallen' can both mean that something comes up as a result of a situation. 'entstehen' is more general: it works for problems, ideas, damage, costs, or new things. 'anfallen' is used mainly for costs, work, or waste—that is, things that you then have to pay for, deal with, or dispose of. The words can be confused because, for example, you can say both that costs 'entstehen' and that costs 'anfallen'. 'anfallen' sounds more practical and emphasizes the burden or task involved.

Bei der Renovierung fallen zusätzliche Kosten an.
Additional costs arise during the renovation.
Bei der Planung entsteht eine gute Idee für das neue Projekt.
During the planning, a good idea for the new project comes up.