Verb + à + infinitive
s'engager
àdans
The constructions
às'engager à + infinitif
Meaning : to commit to doing
Le vendeur s'engage à livrer sous huit jours.
danss'engager dans quelque chose
Meaning : to enter, to get involved in
Il s'est engagé dans une association.
Why
S'engager à before an infinitive is a firm promise, common in contracts. S'engager dans says you are entering an action or a path. The two prepositions do not swap.