There are three possibilities for this issue:
1. Running user for creating Account, Contact and User for Experience Cloud site access doesn’t have a Role.
To fix this issue, assign a Role to the running user.
Reference Article:
2. Creating User for an Experience Cloud site and the account owner of the Contact is not having a Role.
To fix this issue, assign a Role to the Account owner of the Contact record from which the User is getting created.
3. If you are trying to create an User for a Contact and the Contact is not tied to the Account. Make sure AccountId on the Contact is not blank/null.