Ola,
In addition to what Josh wrote, the automatic matching is built from the Payment Application Rules you establish. To set up a Payment Application Rule search for Payment Application Rules. The rules are based on High to Low to indicate the quality of the data matching of the record. The automatic application function is based on prioritized matching criteria. First the function tries, in prioritized order, to match text in the five Related-Party fields on a journal line with text in the bank account, name, or address of customers or vendors with unpaid documents representing open entries. Then, the function tries to match text in the Transaction Text and Additional Transaction Info fields on a journal line with text in the External Document No. and Document No. fields on open entries. Last, the function tries to match the amount in the Statement Amount field on a journal line with the amount on open entries.

On the page, you will see the Matching Confidence, Priority, Related Party Matched, and other fields that define the Application Rule. The above pic are the standard BC generic rules. Here is a link to the documentation on the rules: https://docs.microsoft.com/en-us/dynamics365/business-central/receivables-how-set-up-payment-application-rules
Hope this helps you.
Thanks,
Steve