You can say that borrowing from the markets is riskless for the Fed, because it can always pay back with the printing press.
But lending to the markets is still risky: because market participants don't have a printing press to help fall back on.
(In this case, the Fed often also bought some assets and later sold them; that's financially equivalent enough to lending that it doesn't make a difference here.
Especially if the assets you are buying and selling are bonds.)