beilegen
to enclose
To add something to something else, especially to a letter or shipment.
Bitte legen Sie Ihrem Antrag eine Kopie Ihres Personalausweises bei.
Please enclose a copy of your ID card with your application.

to enclose / settle / heave to
Loading your saved state.
to enclose
To add something to something else, especially to a letter or shipment.
Bitte legen Sie Ihrem Antrag eine Kopie Ihres Personalausweises bei.
Please enclose a copy of your ID card with your application.

'Beilegen' (to enclose/settle/heave to) is a separable verb. The prefix 'bei-' comes at the end in a main clause; in subordinate clauses and in the infinitive, it stays attached to the verb. In the infinitive form with 'zu', 'zu' comes between the prefix and the verb.
Er legt dem Paket eine persönliche Notiz bei.
He encloses a personal note with the package.
When you enclose something with a document or shipment, that shipment is often in the dative. The enclosed object itself is in the accusative.
Dem Brief war ein Foto beigelegt.
A photo was enclosed with the letter.
In the meaning of 'schlichten' (to settle/mediate), 'beilegen' is almost always used with abstract nouns for conflicts. Typical combinations are: 'einen Streit beilegen' (to settle a dispute), 'einen Konflikt beilegen' (to settle a conflict), or 'eine Krise beilegen' (to settle a crisis).
Die Parteien versuchten, ihre Differenzen beizulegen.
The parties tried to settle their differences.
This meaning of 'beilegen' (to heave to) is technical language from seafaring. You can recognize it from words like 'Schiff' (ship), 'Kapitän' (captain), 'Segel' (sail), or 'Sturm' (storm) in the context.
Bei hohem Wellengang musste das Segelboot beilegen.
In heavy seas, the sailboat had to heave to.
to solve / loosen
'lösen' and 'beilegen' can both mean that a difficult matter is brought to an end. However, 'lösen' is much more general: you can solve a problem, a task, or a puzzle. 'beilegen' is used especially for a dispute, conflict, or disagreement. It means that the people involved calm down or resolve the conflict. Learners may confuse the words because a dispute is also a problem. More precisely, though: you solve a problem, but you settle a dispute.

Nach dem Gespräch konnten die Nachbarn ihren Streit endlich beilegen.
After the conversation, the neighbors were finally able to settle their dispute.
Im Zug lösen wir noch schnell die letzte Aufgabe für den Kurs.
On the train, we quickly solve the last task for the course.