The common generalization could be:

Code:

a(n)=polcyclo(h*n,2) for fixed h>0 integer.

For h=1 a(a(p))=M(M(p)) if p and M(p)=2^p-1 is prime.

For h=2 a(a(p))=W(W(p)) if p and W(p)=(2^p+1)/3 is prime.

And you can see this for h>2 also.

Or you can even drop the n=p requirement (ofcourse in this case a(n)!=M(n) for h=1 etc.),

note that we can see a(n)=prime or a(a(n))=prime for composite n values also.