befestigen
to attach
To attach something to another thing so that it sits firmly and does not come loose easily.
Er befestigte das Bild mit einem Nagel an der Wand.
He attached the picture to the wall with a nail.

to attach / fortify
Loading your saved state.
to attach
To attach something to another thing so that it sits firmly and does not come loose easily.
Er befestigte das Bild mit einem Nagel an der Wand.
He attached the picture to the wall with a nail.

The verb is made up of the prefix 'be-' and the adjective 'fest' (firm). It literally means 'to make something firm'. This logic applies to all meanings: to make a shelf firm, to make a castle firm, or to make a relationship firm.
Er befestigte das Seil an einem dicken Ast.
He attached the rope to a thick branch.
The prefix 'be-' is inseparable. It remains firmly attached to the verb stem in all tenses and sentence constructions.
Sie hat das Regal sicher an der Wand befestigt.
She securely attached the shelf to the wall.
When saying where something is attached, you usually use the preposition 'an' with the dative. The pattern is: etwas (accusative) an etwas (dative) befestigen.
Die Lampe wird direkt an der Decke befestigt.
The lamp is attached directly to the ceiling.
The object of the verb reveals the meaning. If it is an object (e.g., sign, mirror), attaching is meant. With a place (e.g., city, fortress), it is about military protection. With an abstract noun (e.g., power, friendship), strengthening is meant.
Der neue Spiegel muss noch im Bad befestigt werden.
The new mirror still has to be attached in the bathroom.
to hang
'hängen' and 'befestigen' can both mean that you put something up or attach it somewhere. 'hängen' is more specific when something is fixed at the top and then hangs freely downward, for example a picture, a jacket, or a lamp. 'befestigen' is more general: something should sit firmly and not come loose easily. It does not have to hang downward. For screws, adhesive tape, or a strap, 'befestigen' often fits. For something on a hook or nail, 'hängen' sounds more natural.

Paul befestigt das Regal mit zwei Schrauben an der Wand.
Paul attaches the shelf to the wall with two screws.
Im Flur hängen wir die nassen Jacken an die Haken.
In the hallway, we hang the wet jackets on the hooks.