# can a whole population sample be considered a random sample? I want to do a z test for 2 population proportions

I want to do a z-test for 2 population proportions to test if the two populations have different probabilities of developing a condition like it says here https://www.socscistatistics.com/tests/ztest/default.aspx

my populations are called A and B and the outcomes are success (developing the condition) and failure (not developing the condition) such that: number of A successes = 20 , number of A failures = 999 980 , number of B successes = 60 , number of B failures = 99 999 940 , total population size = 101 000 000 However I do not know if this test would be valid because

1. I have tested the entire population rather than taken a random sample and https://www.socscistatistics.com/tests/ztest/default.aspx says that one of the requirements is "A random sample of each of the population groups to be compared." . Is it ok that I tested the whole population instead of only taking a random sample?
2. I've read elsewhere that the data for the 2 proportion z test needs to be independent, however the condition in my question is somewhat contagious , so one person developing the condition makes it more likely that those in close contact with him will develop the condition, so the data does not seem truly independent to me like different roles of a dice. However if this were a dealbreaker then it seems like it would be impossible to do any hypothesis tests on diseases in a population or epidemiology since most diseases are not truly independent , and yet hypothesis testing in epidemoiology must occur.

Am I right in hoping that points 1 and 2 are not dealbreakers and it's fine to proceed? If not, how would I test whether population A and population B have different probabilities of developing the condition?