Why we used wilson theorem for all numbers?

Wilson theorem is only for prime numbers. Then how can we apply wilson theorem for all numbers in the question discussed in this question?