Join duplicating the data - SQL Server
Read the definition of sys.dm_hadr_database_replica_states at https://docs.microsoft.com/en-us/sql/relational-databases/system-dynamic-management-views/sys-dm-hadr-database-replica-states-transact-sql?view=sql-server-ver15 - you’ll notice that it says “On the primary replica, this view returns a row for each primary database and an additional row for the corresponding secondary database.”
I recommend you debug this by adding AG_DB.* to your select clause, to see what is in the rows you don’t want.