A second musical theme that directly relates to the notes of the main theme. Different than harmony.
I wouldn’t define counterpoint any differently for JS Bach than I would for Haydn, for example. Counterpoint involves using multiple melodic lines simultaneously. That’s it. There are rules for the kinds of dissonances that may be sounded between these lines, and how those dissonances must resolve…but that’s a topic WAY too complicated for a short answer here!
Bach is counterpoint! The fuge, the invention – it’s all counterpoint. Do a fugal analysis.