You create an extra matrix and every time through the loop you swap the two references. For example,
A1 = np.zeros((m, n))
A2 = np.zeros((m, n))
Anow = A1 # reference, not copy
Aafter = A2
while d < 100:
x = infectAll(Anow, Aafter, n,m,tau)
Anow, Aafter = Aafter, Anow
and infectAll() sweeps over the whole matrix so it would be something like
def infectAll(Ain, Aout, n, m, tau):
for i in range(m):
for j in range(n):
if Anow[i,j] == 0:
Aafter[i,j] = infect(Anow, i, j, n, m, tau)
I like Andrei's more compact code but there is no need to create a new copy of A every time, so the best would be to combine the above technique with Andrei's approach.