When you delete an AWS IAM user in the console, behind the scenes it takes care of deleting the attached resources (the user’s password, access keys, MFA tokens, etc.) first. But if you do this with the CLI, you have to delete the attached resources manually before you can delete the user: see delete-user for the gory details.
I recently found myself needing to delete several dozen IAM users as we migrated to IAM Identity Center. This would have been tedious and error-prone to do in the console, so I wrote a helper script to take care of it: delete_iam_users.py. There are a few other handy scripts in my scripts repository that I’ll add to over time.