Case of equality in Markov's inequality
Solution 1:
Markov inequality is the integrated version of the almost sure inequality $a\mathbf 1_{X\geqslant a}\leqslant X$ hence the equality case happens if and only if $a\mathbf 1_{X\geqslant a}=X$ almost surely, that is, $X\in\{0,a\}$ almost surely.
Solution 2:
Let $X$ be a non-negative random variable with a finite expectation $E(X)$. Markov's Inequality states that in that case, for any positive real number $a$, we have $$\Pr(X\ge a)\le \frac{E(X)}{a}.$$
In order to understand what that means, take an exponentially distributed random variable with density function $\frac{1}{10}e^{-x/10}$ for $x\ge 0$, and density $0$ elsewhere. Then the mean of $X$ is $10$.
Take $a=100$. Markov's Inequality says that $$\Pr(X\ge 100)\le \frac{E(X)}{100}=\frac{10}{100}.$$
It is straightforward to show that for this exponential, we have $\Pr(X\ge 100)=e^{-100/10}$. This is a number that is very close to $0$.
Note that the Markov Inequality did not lie. The probability that $X\ge 100$ really is $\le \frac{1}{10}$. But $e^{-10}$ is very much less than $\frac{1}{10}$. So in this case the Markov Inequality produced a correct but lousy bound for the "tail probability" of the exponential.
Could we produce a general but better bound. Yhe purpose of the exercise is to show that in a sense we cannot.
That is the price we pay for having a theorem that applies to all random variables that have a finite expectation. The bound produced by the Markov Inequality is often not at all sharp.
The question asks us, given a positive integer $a$, to produce a random variable $X=X_a$ such that $\Pr(X\ge a)=\frac{E(X)}{a}$.
We can produce a very boring random variable that will do the job. Let $X=a$ with probability $1$. Then $\Pr(X\ge a)=1$. You should show that in this case, $\frac{E(X)}{a}=1$. That will show that it is perfectly possible to have $\Pr(X\ge a)$ exactly equal to $\frac{E(X)}{a}$.