"Add member to groups" action will only work for Office 365 Group (which are mail enabled)
"Add user to Group" action will work for both the cases i.e. Office 365 Group (Mail enabled) or Normal security Group
So in your case if you have both the scenario then you should use action "Add User to group".
Make sure that "Add user to group" action will except only "GroupId" and "UserId" as input so you will need user additional actions to grab those details based on group name and user principal name.
Official Documentation
Add User to group (Azure AD): https://docs.microsoft.com/en-us/connectors/azuread/#add-user-to-group
Add Member to group(Office 365 Groups) : https://docs.microsoft.com/en-us/connectors/office365groups/#add-member-to-group
Hope it will help to you. Please mark this as answer if it works for you.