If Matt made M cookies then Phil made M+0.25M=1.25M cookies.
Each cookie sells at $0.25 so Phil raised 1.25×0.25M dollars=$0.3125M. That means that if Matt made 100 cookies then Phil would make $31.25.
Matt and Phil together made M+1.25M=2.25M cookies. If 20% remained after the sale, then they sold 80% of the cookies and made 0.80×0.25×2.25M dollars=0.45M dollars.
So the required equation is S=0.45M dollars, where S is the money raised by the sale of the cookies.
(If Matt made 100 cookies then Phil made 125, and together they made 225 cookies, which would have sold for $56.25. But 20% of the cookies (45 cookies) remained, so they only sold 180 cookies which earned them $45. The equation also confirms this amount when M=100.)