The formula was given by Iglewicz and Hoaglin$^1$ (reference below).
Let the mad for a vector $x$ of $n$ observations be defined as $m(x) = \text{median}(|x- \text{median}(x)|)$. If $x$ is normally distributed, it can be shown that
$$
\lim_{n\rightarrow \infty}E(m(x)) = \sigma\Phi^{-1}(0.75)
$$
where $\Phi^{-1}(0.75) \approx 0.6745$ is the $0.75^\text{th}$ quantile of the standard normal distribution and is used for consistency. That is, so that
$m(x)/0.6745$ is a consistent estimator of the standard deviation $\sigma$.
If you can't assume normality, you can use the 0.75$^\text{th}$ quantile of any other distribution that is symmetric about some value (not necessarly the mean) standardised to have mean 0 and standard deviation 1. Typically a t-distribution is used if fat-tail are assumed.
Iglewicz and Hoaglin suggest using $\pm3.5$ as cut-off value but this a matter of choice ($\pm3$ is also often used).
$^1$ Boris Iglewicz and David Hoaglin (1993), "Volume 16: How to Detect and Handle Outliers", The ASQC Basic References in Quality Control: Statistical Techniques, Edward F. Mykytka, Ph.D., Editor.