Let $F$ be the distribution of $X,$ as in the question, and $F_n$ be the distribution for a median $T_n$ of a sample of $n$ iid variables $X_i$ distributed like $X.$ (Since the median is usually not uniquely defined for even $n,$ we have to be a little open-minded about $T_n$ and $F_n$! More about this below.) Then, by the very definition of any median, for all real numbers $x$ the event $$T_n \le x$$ is identical to the event "at least $n/2$ of the $X_i$ are less than or equal to $x.$" For any $i,$ the chance of $X_i \le x$ is given by $F(x)$ and because the $X_i$ are independent, the chance that $T_n \le x$ is given by a tail probability for the Binomial distribution with parameters $n$ and $F(x).$
Suppose $F=F_n$ for some $n$ to be determined as appropriate to produce interesting results. The cases $n=1$ and $n=2$ yield no useful information, but consider the case $n=3.$ Then because "at least $n/2$" means "$2$ or $3$," we obtain
$$F(x) = F_3(x) = \Pr(T_3 \le x) = \binom{3}{2}F(x)^2(1-F(x)) + \binom{3}{3}F(x)^3.$$
This is a cubic equation in $F(x)$ whose only solutions are $\{0,1/2,1\}.$ This limits $X$ to random variables having positive probabilities of attaining at most two values (namely, the point where the jump from $0$ to $1/2$ occurs and the point where the jump from $1/2$ to $1$ occurs). For nonconstant $X$ these are the affine transformations of Bernoulli$(1/2)$ variables. In other words, either $X$ is constant or there exist distinct numbers $x_0, x_1$ and $$\Pr(X=x_0) = \Pr(X=x_1)=\frac{1}{2}.$$
For such variables to have the same distribution as the median $T_n$, you need to define medians in such a way that guarantees they are possible values of $X.$ However you do it, it's clear that for these "affine Bernoulli" variables the median also has equal chances of being either $x_0$ or $x_1$ and so obviously has the same distribution as $X$ itself.