Consider $\vec{a} = (a_x, a_y), \vec{b} = (b_x, b_y) \in \mathbb{R}^2$. We can rewrite the first formula as \vec{p} = \left( \vec{a} \cdot \frac{\vec{b}}{\|\vec{b}\|}\right) \frac{\vec{b}}{\|\vec{b}\|} = \frac{\vec{a} \cdot \vec{b}}{\| b \|^2} \vec{b}. (Here $ \vec{a} \cdot \vec{b} := a_x b_x + a_y b_y $ is the dot product of vectors in $\mathbb{R}^2$, and $\| \vec{a} \| := \sqrt{a_x^2 + a_y^2}$ denotes the vector norm or length, in case you didn't know).
This is a standard formula, and $\vec{p}$ is called the orthogonal projection $\vec{a}$ onto the line spanned by the vector $\vec{b}$ (the reason for the name is that $\vec{a} - \vec{p}$ is perpendicular to $\vec{b}$, i.e. $(\vec{a} - \vec{p})\cdot \vec{b} = 0$).
I am not sure what the second formula is supposed to be; it looks like you have forgotten a parenthesis, so I guess it is supposed to be \frac{a_x (o_x + tx) + a_y(o_y + ty)}{\| a \|^2} (I have replaced $p_x$ and $p_y$ with $o_x$ and $o_y$ in order to avoid notational conflicts). If all quantities involved are numbers, then this is also a number, so it cannot be the complete formula for a projection. Provided you've copied it correctly, I'd say it looks like the scalar part of the formula for the orthogonal projection given above, but where the vector being projected is $(o_x + tx, o_y + ty) = (o_x, o_y) + t(x,y)$ (this would correspond to specifying the vector using a point of origin $(o_x, o_y)$, a direction vector $(x,y)$ and a distance $t$ along the direction vector). But then the formula should read $ \frac{a_x (o_x + tx) + a_y(o_y + ty)}{\| a \|^2} (a_x, a_y). $ If that is the case, it is equivalent to the previously given formula; the only difference is that the coordinates of the vector being projected is specified differently.