MariaDB handling composite unique indexes that are foreign keys at the same time
This is documented behaviour:


  MySQL requires indexes on foreign keys and referenced keys so that
  foreign key checks can be fast and not require a table scan. In the
  referencing table, there must be an index where the foreign key
  columns are listed as the first columns in the same order. Such an
  index is created on the referencing table automatically if it does not
  exist. This index might be silently dropped later if you create
  another index that can be used to enforce the foreign key constraint.
  index_name, if given, is used as described previously.


Multiple indexes over the same columns are allowed, but deprecated (as it is redundant- there is almost nothing that the non-unique key can do that the unique index cannot), and may error out in the future (although probably not for different index types like this case).

My suggestion, to prevent confusion, is to just create the unique index (or any explicit index that is adequate with a custom name) from the beginning. I agree with you, that this could be confusing, so looking at the manual is always a great idea, and I believe the current implementation make sense from a compromise between control and optimization perspective. :-)