Goldman Sachs and Morgan Stanley both reported a rise in quarterly profit, helped by a flurry of dealmaking.