Due to the fact that
$\forall x,c \in \mathbb{R}, \\|x-c| = (x-c)\unicode{x1D7D9}_{\{x>c\}} + (c-x)\unicode{x1D7D9}_{\{x\leq c\}} \\= \int_c^x \unicode{x1D7D9}_{\{x>c\}} \,dt + \int_x^c \unicode{x1D7D9}_{\{x \leq c\}} \,dt \\ = \int_c^{\infty} \unicode{x1D7D9}_{\{t<x\}} \,dt + \int_{-\infty}^{c} \unicode{x1D7D9}_{\{t \geq x\}} \,dt,$
$\forall$ continuous real-valued random variable $X$, $c \in \mathbb{R},$ by linearity of expectation,
$\mathbb{E}[|X-c|] = \mathbb{E}[(X-c)\unicode{x1D7D9}_{\{X>c\}}] + \mathbb{E}[(c-X)\unicode{x1D7D9}_{\{X\leq c\}}] $
$=\int_{-\infty}^{\infty} \int_c^{\infty} \unicode{x1D7D9}_{\{x>t\}} \,dt \,dx + \int_{-\infty}^{\infty} \int_{-\infty}^c \unicode{x1D7D9}_{\{x \leq t\}} \,dt \,dx.$
Since random variable and indicator function are measurable, by Fubini's theorem,
$= \int_c^{\infty} \int_{-\infty}^{\infty} \unicode{x1D7D9}_{\{t<x\}} \,dx \,dt + \int_{-\infty}^c \int_{-\infty}^{\infty} \unicode{x1D7D9}_{\{t \geq x\}} \,dx \,dt$
$=\int_c^{\infty} \mathbb{E}[\unicode{x1D7D9}_{\{t<X\}}] \,dt + \int_{-\infty}^c \mathbb{E}[\unicode{x1D7D9}_{\{t \geq X\}}] \,dt\\= \int_c^{\infty} \mathbb{P}(X>t) \,dt + \int_{-\infty}^c \mathbb{P}(X \leq t) \,dt.$
By Leibniz's integral rule, the first-order condition of $\mathbb{E}[|X-c|]$ is
$0=\partial_c \mathbb{E}[|X-c|] = (0-\mathbb{P}(X > c)) + (\mathbb{P}(X \leq c) - 0)$
$\implies 2\mathbb{P}(X \leq c) -1 = 0 \implies \mathbb{P}(X \leq c) = \frac{1}{2} = \mathbb{P}(X > c) = \mathbb{P}(X \geq c)$.
The last inequality holds since $X$ is a continuous real-valued random variable. The probability measure of a singleton is of measure $0$.
By definition, $c$ is the median of $X$ when $\mathbb{E}[|X-c|]$ is minimized.