Some of the music was written quickly in a kind of shorthand. If you as a harpsichordist were expected to write a new piece for flute and harpsichord to be performed tonight, you would probably just write a lead sheet for the harpsichord part and wing it from that. The Baroque equivalent is "figured bass": just the bass notes with numbers indicating the chords.
You would write the melody for the flute, but the style of playing at the time was to have lots of grace notes, mordents, flourishes and scales and so on. Most likely you wouldn't take the time to write them into the score; you'd let the flute player go wild.
It wasn't exactly like modern jazz improvisation; the soloist would still play all the written notes, and just lots of little ones besides.
J.S. Bach generally took the time to write down full accompaniments and to write in the mordents and other stuff. Maybe he didn't like what he heard when other players improvised and he knew he could write better than they could improvise. Or maybe he was just showing you one sample way of interpreting it. Very few of the other composers took that much care with their notation.
Rule of thumb: if the keyboard part is just single bass notes, play chords and stuff. If it looks like it's all worked out for you, play it as written. Play the keyboard parts from some Bach solo sonatas and trio sonatas to get a feel for what a good accompaniment sounds like.