The Z-test is for normally distributed means where the variance (standard deviation) is known. Typically we talk about "the data are normally distributed", but yours clearly are not because each datum can take only two values, positive or negative for the particular attribute of interest. Normally distributed values can take any real value. The data that you feed to the Z-test should be random samples, and you have not indicated that yours are random and so I suspect that they might be 'convenience samples' that would not support detailed inferences about populations.
As German Demidov said in his comment, the 'two by two' test called 'Fisher's exact test' would be appropriate for your data as it tests for a difference between two proportions. There are alternatives to that test that have slightly different assumptions about conditioning, see here and here for example. However, it's quite likely that you should not be testing at all.
Your results indicate that the attribute of interest is unusual in the populations sampled. That means that the observed sample proportion is a very rough index of the population proportion. If the true rate was 1 out of 40 then your observed proportions would be entirely unsurprising. They would also be unsurprising if the true rate was 1/25 or 1/75. There's just not very much information in the sample about a small proportion. All of that is a long-winded way of saying that your samples are way, way too small for any useable power in any test of small proportions. Test however you like and the result will be a large P-value.
Consider simply presenting the data and confidence intervals. See this question.