If the Fed buys $1000 worth of securities from commercial banks, the excess reserves will increase by $1000. Then, the money supply will increase by $1000*5=$5000.

If they buy securities from the public, the public gets more money, and when they deposit it into banks (whether directly or indirectly), bank reserves increase. However, since the required reserve ratio is 0.2, the bank needs to put $200 of the money in the Federal Reserve Bank, and so excess reserves only increase by $800. Then, the money supply will increase by $800*5=$4000