Start with the full equation
$$f(x) = \frac{1}{\sqrt{4 \pi D t}} \exp \left( -x^2 / 4Dt \right) \, . $$
Here $D$, called the diffusion constant, has dimensions of $[\text{length}]^2/[\text{time}]$.
A lot of physicists like to get rid of constants like this to make hand calculations and computer numerical computations easier.
In this case, you can see that you get your second equation if you set $D=1/2$.
Similarly you'll often hear people say stuff like "here we set $c=1$ ($c$ is the speed of light).
This is horrible abuse of language!
You probably want to ask why we can just randomly set $D=1/2$ or $c=1$.
Here's a much better way to think about it.
Define a new time variable $t' \equiv 2Dt$.
This new variable has dimensions of $[\text{length}]^2$.
Plugging that into the equation, we get
$$f(x) = \frac{1}{\sqrt{2\pi t'}} \exp \left(-x^2/2t'\right) \, . $$
This is better for several reasons:
The ratio $x^2/2t'$ is properly dimensionless, whereas $x^2/2t$ has dimensions of $[\text{length}]^2/[\text{time}]$.
You can now switch between the $t'$ version and the $t$ version with the $D$ included by explicit substitution that makes sense. This is important if you run a numerical computation and then want to understand what happens when you vary $D$.
It's way more explicit than just writing the $t'$ version and not saying that $t'$ actually has different dimensions than $t$.