With SQL Server 2017, you need to manually keep accounts on the different replicas synced. All works best if you are using Windows authentication, but if you need to use SQL Server authentication, make sure that if you recreate a login on a replica, that you use the same security ID (SID) when recreating the login.
In SQL Server 2022, there are options now that didn't exist before, if you have a contained availability group: https://learn.microsoft.com/en-us/sql/database-engine/availability-groups/windows/contained-availability-groups-overview?view=sql-server-ver16