As our example bicep template suggests that every policy assignment needs to have dependency relationship with previous operation. i.e. one cannot initiate multiple policy assignments in one go, it needs to be sequential one by one using depdensOn property which make sure the 2<sup>nd</sup> policy assignment does not initiate until 1<sup>st</sup> one is completed.
The bicep template you shared uses a for loop to assign all of the principal without any depdensOn relationship causes all policy assignment operation to start without waiting previous one to complete hence all subsequent after first assignment operation gets failed.
We recommend you to use dependency relationship among all assignment operations using depdensOn property in your bicep template.
If you want to use existing for loop using dependsOn property may get tricky.
Alternate approach is to use “batchSize” decorator with value 1 in such cases to make them sequential.
This is the doc link for batchSize: https://learn.microsoft.com/en-us/azure/azure-resource-manager/bicep/loops#deploy-in-batches
I hope this information helps.