There are $\frac{40!}{2^{20}}$ ways to put the players into the rooms, with no conditions.
If we were to put the defensive with the defensive, there are $\binom{20}{10}$ ways to pick the rooms for the defensive men, and then $\frac{20!}{2^{10}}$ ways to put the defensivement in those rooms, and $\frac{20!}{2^{10}}$ ways to put the offensive men in the other rooms, for a total of:
$$\binom{20}{10}\frac{20!20!}{2^{20}}$$
That means that the probability should be $$\frac{\binom{20}{10}\frac{20!20!}{2^{20}}}{\frac{40!}{2^{20}}}=\frac{20!^3}{10!10!40!}\approx 1.3\times 10^{-6}$$
More general, in a team with $2a$ offensive and $2b$ defensive, and $a+b$ rooms, you'd get:
$$\frac{(2a+2b)!}{2^{a+b}}$$ different ways of putting the players in the room, and $$\binom{a+b}{a}\frac{(2a)!}{2^a}\frac{(2b)!}{2^b}$$
different ways up putting the payers together by type, yielding a probability of:
$$\frac{(a+b)!(2a)!(2b)!}{a!b!(2a+2b)!}$$
In your case, $a=b=10$.
Even more generally, if each room holds $k$ players, and you have $m$ positions with $ka_i$ players of position $i=1,\dots,m$, then the number of ways of arbitrarily rooming the players is:
$$\frac{(k(a_1+\dots+a_m))!}{(k!)^{a_1+\dots+a_m}}$$
The number of ways of picking the rooms with each room having only players of one position is:
$$\binom{a_1+\dots+a_m}{a_1,\dots,a_m}\prod_{i=1}^m \frac{(ka_i)!}{(k!)^{a_i}}$$
Taking the ratio, we get:
$$\frac{(a_1+\dots+a_m)!(ka_1)!(ka_2)!\dots(ka_m)!}{(k(a_1+\dots+a_m))!a_1!\dots a_m!}$$
If $n=a_1+\dots a_m$ is the number of rooms, then this is:
$$\frac{\binom{n}{a_1,\dots,a_m}}{\binom{kn}{ka_1,\dots,ka_m}}$$
That's an interesting formula. The way to think of it is in terms of assigning the players positions after their rooms. There are $\binom{kn}{ka_1,\dots,ka_m}$ ways to assign the positions, total, but once the players are put in the rooms, if the condition is that each room must contain players of one type, then there are $\binom{n}{a_1,\dots,a_m}$ ways of assigning the positions to the players that match the room assignments.