In this About Customer Portal User Management help page, under Customer Portal Role Hierarchy,
When you enable a Customer Portal on an account, the system creates a
role hierarchy for the account’s portal users. The portal roles are
unique for each account and include the account’s name—or example,
“Account A Customer User.” In your organization’s overall role
hierarchy, this account-specific hierarchy is directly below the
What you experience is the default behavior of Salesforce while creating Customer portal users. If you want to see the Customer Portal roles, go the role of the Account Owner and then you can see the hierarchy under that role.
If you are creating portal user in test class, you don't need to assign role to the user. Once you assign a contact associated with an account to contactId field of the user and insert it, salesforce will automatically assign the role to the user based on the account name as mentioned(Account A Customer User) in the help document
Hope it helps.